O'Reilly logo

Microsoft® SQL Server® 2008 Step by Step by Mike Hotek

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deleting Data

If you need to remove data from a table, you can execute a DELETE statement, which has a general syntax of:

DELETE
    [ TOP ( expression ) [ PERCENT ] ]
[ FROM ]     { <object> | rowset_function_limited
      [ WITH ( <table_hint_limited> [ ...n ] ) ]}

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

The simplest form of a DELETE statement only requires a table name with the FROM keyword being optional. Therefore, DELETE Products.Product is equivalent to DELETE FROM Products.Product. It is recommended that you utilize the FROM keyword for both clarity and readability so that someone reading your code ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required