Deleting Existing Data

The DELETE statement is used to delete existing rows of data from a database. Listing 4.6 shows the basic structure of the DELETE statement.

Listing 4.6. The Basic Structure of the DELETE Statement
DELETE
    [ FROM ]
        { table_name WITH ( < table_hint_limited > [ ...n ] )
         | view_name
         | rowset_function_limited
        }

        [ FROM {  < table_source > }  [ ,...n ] ]
    [ WHERE
        {  < search_condition >
        | {  [ CURRENT OF
                {  {  [ GLOBAL ] cursor_name }
                    | cursor_variable_name
                }
            ] }
        }
    ]
    [ OPTION ( < query_hint > [ ,...n ] ) ]

The DELETE statement will completely wipe out a row, so be careful! If you accidentally ran the statement DELETE Products, every row in the Products table would be deleted. Use the following DELETE statement to delete the row you ...

Get Programming Data-Driven Web Applications with ASP.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.