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

About this user

Dave http://pedotnet.blogspot.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

DELETE - SQL

// description of your code here

   1  
   2  DELETE ... 
   3      [ FROM ... ] 
   4      [ ... JOIN ... ] 
   5      [ WHERE ... ] 
   6  
   7  // FULL Syntax follows:
   8  DELETE [ FROM ] 
   9      {
  10         [ database. ] [ owner. ] table_name 
  11           [
  12             WITH (  INDEX ( Index_1,   [ index_2,  ...,  n ] ) 
  13                        | FASTFIRSTROW 
  14                        | HOLDLOCK 
  15                        | PAGLOCK 
  16                        | READCOMMITTED 
  17                        | REPEATABLEREAD 
  18                        | ROWLOCK 
  19                        | SERIALIZABLE 
  20                        | TABLOCK 
  21                        | TABLOCKX 
  22                        [   ...   n  |  ...,  n ] 
  23                       )
  24         ]
  25       |
  26         OPENQUERY( server, 'query' ) 
  27       |
  28         OPENROWSET( 'provider_name', 
  29                                   { 'datasource';'user_id';'password',  |  'provider_string', }
  30                                   { [ catalog. ] [ schema. ] object  |  'query' }
  31                                 ) 
  32       |
  33         view_name 
  34      }
  35  
  36      [
  37        FROM 
  38        {
  39            derived_table 
  40              [ [ AS ] table_alias ]
  41              [ ( column_alias_1,   [ column_alias_2,   ...,  n ]  )  ]
  42          |
  43            CONTAINSTABLE ( table, column  |  *, 'search_conditions' ) 
  44              [ [ AS ] table_alias ]
  45          |
  46            FREETEXTTABLE ( table, column  |  *, 'free_text_string' ) 
  47              [ [ AS ] table_alias ]
  48          |
  49            table_name [ [ AS ] table_alias ]
  50              [
  51                 WITH (  INDEX ( Index_1,   [ index_2,   ...,  n ]  ) 
  52                            | FASTFIRSTROW 
  53                            | HOLDLOCK 
  54                            | NOLOCK 
  55                            | PAGLOCK 
  56                            | READCOMMITTED 
  57                            | READPAST 
  58                            | READUNCOMMITTED 
  59                            | REPEATABLEREAD 
  60                            | ROWLOCK 
  61                            | SERIALIZABLE 
  62                            | TABLOCK 
  63                            | TABLOCKX 
  64                            | UPDLOCK 
  65                            [ ...   n  |  ...,  n ] 
  66                           )
  67              ]
  68          |
  69            view_name [ [ AS ] table_alias ]
  70        }
  71  
  72  
  73  
  74  
  75  
  76        [
  77            INNER JOIN  |  LEFT [ OUTER ] JOIN  |  RIGHT [ OUTER ] JOIN 
  78              {
  79                 derived_table [ ON search_conditions ]
  80               |
  81                 OPENQUERY( server, 'query' ) [ ON search_conditions ]
  82               |
  83                 OPENROWSET
  84                                 ( 'provider_name', 
  85                                   { 'datasource';'user_id';'password',  |  'provider_string', }
  86                                   { [ catalog. ] [ schema. ] object  |  'query' }
  87                                 ) [ ON search_conditions ]
  88               | 
  89                 table_name [ ON search_conditions ]
  90               | 
  91                 view_name [ ON search_conditions ]
  92              }
  93              [   ...,  n ]
  94            |
  95            CROSS JOIN  |  FULL [ OUTER ] JOIN 
  96              {
  97                 derived_table 
  98               | 
  99                 OPENQUERY( server, 'query' ) 
 100               |
 101                 OPENROWSET
 102                                 ( 'provider_name', 
 103                                   { 'datasource';'user_id';'password',  |  'provider_string', }
 104                                   { [ catalog. ] [ schema. ] object  |  'query' }
 105                                 ) 
 106               | 
 107                 table_name 
 108               | 
 109                 view_name 
 110              }
 111              [   ...,  n ]
 112         ]
 113     ] 
 114  
 115     [
 116        {
 117           WHERE search_conditions 
 118         |
 119           WHERE CURRENT OF [ GLOBAL ] cursor_name 
 120         |
 121           WHERE CURRENT OF cursor_variable_name 
 122        }
 123           [
 124             OPTION (  FAST number_rows 
 125                            | FORCE ORDER 
 126                            | HASH GROUP 
 127                            | ORDER GROUP 
 128                            | HASH JOIN 
 129                            | LOOP JOIN 
 130                            | MERGE JOIN 
 131                            | KEEP PLAN 
 132                            | MAXDOP 
 133                            | ROBUST PLAN 
 134                            | CONCAT UNION 
 135                            | HASH UNION 
 136                            | MERGE UNION 
 137                            [   ...,  n ]
 138                          )
 139           ]
 140     ]

//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.
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS