Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

DELETE - SQL (See related posts)

// description of your code here

DELETE ... 
    [ FROM ... ] 
    [ ... JOIN ... ] 
    [ WHERE ... ] 

// FULL Syntax follows:
DELETE [ FROM ] 
    {
       [ database. ] [ owner. ] table_name 
         [
           WITH (  INDEX ( Index_1,   [ index_2,  ...,  n ] ) 
                      | FASTFIRSTROW 
                      | HOLDLOCK 
                      | PAGLOCK 
                      | READCOMMITTED 
                      | REPEATABLEREAD 
                      | ROWLOCK 
                      | SERIALIZABLE 
                      | TABLOCK 
                      | TABLOCKX 
                      [   ...   n  |  ...,  n ] 
                     )
       ]
     |
       OPENQUERY( server, 'query' ) 
     |
       OPENROWSET( 'provider_name', 
                                 { 'datasource';'user_id';'password',  |  'provider_string', }
                                 { [ catalog. ] [ schema. ] object  |  'query' }
                               ) 
     |
       view_name 
    }

    [
      FROM 
      {
          derived_table 
            [ [ AS ] table_alias ]
            [ ( column_alias_1,   [ column_alias_2,   ...,  n ]  )  ]
        |
          CONTAINSTABLE ( table, column  |  *, 'search_conditions' ) 
            [ [ AS ] table_alias ]
        |
          FREETEXTTABLE ( table, column  |  *, 'free_text_string' ) 
            [ [ AS ] table_alias ]
        |
          table_name [ [ AS ] table_alias ]
            [
               WITH (  INDEX ( Index_1,   [ index_2,   ...,  n ]  ) 
                          | FASTFIRSTROW 
                          | HOLDLOCK 
                          | NOLOCK 
                          | PAGLOCK 
                          | READCOMMITTED 
                          | READPAST 
                          | READUNCOMMITTED 
                          | REPEATABLEREAD 
                          | ROWLOCK 
                          | SERIALIZABLE 
                          | TABLOCK 
                          | TABLOCKX 
                          | UPDLOCK 
                          [ ...   n  |  ...,  n ] 
                         )
            ]
        |
          view_name [ [ AS ] table_alias ]
      }





      [
          INNER JOIN  |  LEFT [ OUTER ] JOIN  |  RIGHT [ OUTER ] JOIN 
            {
               derived_table [ ON search_conditions ]
             |
               OPENQUERY( server, 'query' ) [ ON search_conditions ]
             |
               OPENROWSET
                               ( 'provider_name', 
                                 { 'datasource';'user_id';'password',  |  'provider_string', }
                                 { [ catalog. ] [ schema. ] object  |  'query' }
                               ) [ ON search_conditions ]
             | 
               table_name [ ON search_conditions ]
             | 
               view_name [ ON search_conditions ]
            }
            [   ...,  n ]
          |
          CROSS JOIN  |  FULL [ OUTER ] JOIN 
            {
               derived_table 
             | 
               OPENQUERY( server, 'query' ) 
             |
               OPENROWSET
                               ( 'provider_name', 
                                 { 'datasource';'user_id';'password',  |  'provider_string', }
                                 { [ catalog. ] [ schema. ] object  |  'query' }
                               ) 
             | 
               table_name 
             | 
               view_name 
            }
            [   ...,  n ]
       ]
   ] 

   [
      {
         WHERE search_conditions 
       |
         WHERE CURRENT OF [ GLOBAL ] cursor_name 
       |
         WHERE CURRENT OF cursor_variable_name 
      }
         [
           OPTION (  FAST number_rows 
                          | FORCE ORDER 
                          | HASH GROUP 
                          | ORDER GROUP 
                          | HASH JOIN 
                          | LOOP JOIN 
                          | MERGE JOIN 
                          | KEEP PLAN 
                          | MAXDOP 
                          | ROBUST PLAN 
                          | CONCAT UNION 
                          | HASH UNION 
                          | MERGE UNION 
                          [   ...,  n ]
                        )
         ]
   ]

//Full explanation follows:

KEYWORDS Keywords are denoted with upper case letters. Obey the spelling.

variables All user-supplied variables are denoted with lower case letters.

..., n Signifies that there can be more than one value in a comma delimited list. Note that the dots and n are not part of the code and must not appear in the SQL query.

... n Signifies that there can be more than one value in a blank space delimited list. Note that the dots and n are not part of the code and must not appear in the SQL query.

{ } Signifies that all, or some portion, of the code elements between the braces are required elements and must appear in the SQL query. Note that these braces are not part of the code and must not appear in the SQL query.

[ ] Signifies that the code elements between the square brackets can optionally appear in the SQL query, but are not required. Note that these brackets are not part of the code and must not appear in the SQL query.

| The or symbol signifies that you may use only one of the code elements or values from the possible choices. Note that the or symbol is not part of the code and must not appear in the SQL query.

Comments on this post

asil posts on Oct 23, 2009 at 14:44
Thank you for sharing and technical informations. This article I want to share with my other friends. Regards.

----------------------------------
Chat, Chat odaları, Sohbet
ohyeah posts on Oct 29, 2009 at 09:28
Awesome! Need a pair of Nike Shoes? Im good at Jordan Shoes FAQ and also the Nike Shoes, so if you’re ready to buy a pair nike shoes or Jordan Shoes, I can help you something, if you just like the UGG Boots, I have no way to do that XD! See you then..
ohyeah posts on Nov 02, 2009 at 01:27
Sounds good! I wonder if you like the basketball games? Im the sneaker collector, and I like Basketball Shoes so much. That’s why you saw me here. Also, my sister ask me to find some UGG Boots useful news, can you help me? Thanks!
weiliu posts on Nov 05, 2009 at 05:15

You need to create an account or log in to post comments to this site.


Click here to browse all 7309 code snippets

Related Posts