Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Transact-SQL
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Changes to DELETE and UPDATE statements== In Transact-SQL, both the <code>DELETE</code> and <code>UPDATE</code> statements are enhanced to enable data from another table to be used in the operation, without needing a subquery: * <code>DELETE</code> accepts joined tables in the <code>FROM</code> clause, similarly to <code>SELECT</code>. When this is done, the name or alias of which table in the join is to be deleted from is placed between <code>DELETE</code> and <code>FROM</code>. * <code>UPDATE</code> allows a <code>FROM</code> clause to be added. The table to be updated can be either joined in the <code>FROM</code> clause and referenced by alias, or referenced only at the start of the statement as per standard SQL. This example deletes all {{code|users}} who have been flagged in the {{code|user_flags}} table with the 'idle' flag. <syntaxhighlight lang="tsql"> DELETE u FROM users AS u INNER JOIN user_flags AS f ON u.id = f.id WHERE f.name = 'idle'; </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)