Saturday, August 20, 2011

HOW TO USE DELETE STATEMENT SYNTAX IN SQL SERVER

The delete statement is use to delete rows from a table

The syntax of Delete statement is

Delete from table_name
where column_name='value'

lets say we have a table (name table_1) like this


and we want to delete those tuple who's city is karachi

so the syntax would be

Delete from table_1
Where city = 'karachi'

This will delete all tuples who's city is karachi, so the result set would be


Note : Make sure you use where clause with delete statement without it you can accidentally delete whole table.

For instance we a table

if we use

delete from table_1

This will remove all the records in a table so be care while using delete statement.

No comments:

Post a Comment