question

sandyTWG avatar image
sandyTWG asked

Rewriting a pre-2005 script without a FROM phrase in current usage

UPDATE DataAsOf SET DateLoaded = NULL WHERE Tablename = @strTableName
update
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

JohnM avatar image JohnM commented ·
I'm confused. What are you looking to accomplish? Can you please clarify?
0 Likes 0 ·
sandyTWG avatar image sandyTWG commented ·
I do not understand how a query can be writen without a from phrase. This script is currently working, setting the column DataAsOf to null in the table @strTableName. If this is current code, how does it work?
0 Likes 0 ·

1 Answer

·
Shawn_Melton avatar image
Shawn_Melton answered
Please read the manual: [UPDATE (Transact-SQL)][1] UPDATE statement does not require a FROM clause. You would only include a FROM clause if you wanted to join to other tables to get values, or you are updating values in Table1 from Table2. More details on UPDATE can be found here: [UPDATE Basics in SQL Server][2] [1]: https://msdn.microsoft.com/en-us/library/ms177523.aspx [2]: https://www.simple-talk.com/sql/learn-sql-server/update--basics-in-sql-server/
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.