All Type Coding

Search Here

How to delete data from a table in sql server.?

Delete Statement:
                              It is used to delete records in a table and use WHERE clause with DELETE command to delete selected rows, otherwise all the records would be deleted in a table

Syntax of Delete statement.

                           DELETE FROM Table_Name
                           WHERE column=value;

In this tutorials we'll learn how to delete data or record from table 

Step1. create a table




















Step2. Insert data into table.
Before inserting the data into table  set identity YES and set primary key on column Id
By the identity property  id number will be auto-incremented and very helpful to select,Delete,Update  the record uniquely.









































after that insert data into table.

insert data into tblEmployee1

insertinto tblEmployee1 values('AAA',5000,'Female')
insertinto tblEmployee1 values('BBB',1000,'male')
insertinto tblEmployee1 values('CCC',4000,'Female')
insertinto tblEmployee1 values('DDD',8000,'male')
insertinto tblEmployee1 values('EEE',6000,'Female')
insertinto tblEmployee1 values('FFF', 9000,'male')
insertinto tblEmployee1 values('GGG',4000,'male')


































Step3. Execute the select statement 

--Execute the select Command
   Select*from tblEmployee1

































Step4. Now we'll run the delete query 












Step5.
Run once again select statement.
   you are seeing below image the id 7 is deleted from table 






















Now we want to delete all data from database table.let's see how to delete all data from data base 
run below query
                           Delete from Employee1
After executing the above query all data deleted from database table.when will you execute the select statement no data display in the table.

No comments :

Post a Comment