Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

UPDATE Expand / Collapse
Author
Message
Posted Thursday, September 24, 2009 8:21 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 5:28 AM
Points: 2,114, Visits: 5,502
Like others I didn’t know what to answer. I know that FROM clause can be used in an update statement, but I also noticed that the way that the example was written, it shouldn’t work. I decided to ignore the example and give the correct answer for the question only, but I can understand why many users wrote no because of the example.

Adi


--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #793302
Posted Thursday, September 24, 2009 8:50 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, May 29, 2012 2:50 AM
Points: 190, Visits: 88
skjoldtc (9/24/2009)
A suggestion for future questions. Maybe not all questions need sample code.


Although some questions very well could be written without sample code I think it is generally a good idea to have code along with a T-SQL question like this. But - the code should be correct, unless the purpose of the question is to spot the error.

Post #793337
Posted Thursday, September 24, 2009 9:13 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, June 27, 2012 7:28 AM
Points: 18, Visits: 46
I answered no because the code does not work. Oh, well!
Post #793361
Posted Thursday, September 24, 2009 9:14 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Wednesday, October 15, 2014 1:48 PM
Points: 732, Visits: 411
My apology guys.

The example provided makes the question confusing.

Post #793362
Posted Thursday, September 24, 2009 9:51 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Yesterday @ 3:56 PM
Points: 96, Visits: 100
I too answered 'no' based upon the example...perhaps the example shouldn't have been given and just the question asked, but if you ran the given statement, it would certainly fail due to:

update table <-- [table]
set a1.coulmn=a2.column <-- COULMN [misspelled]
from table1 as a1, table2 as a2
where a1.colum1 = a2.column2 <-- COLUM [misspelled]

Was this ever QA'd? If I was handed this script to apply to production, I wouldn't have to see it fail to kick it back to the author and tell them to clean it up...
Post #793399
Posted Thursday, September 24, 2009 9:58 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 8:06 AM
Points: 3,966, Visits: 3,645
Aditya Kota (9/24/2009)
My apology guys.

The example provided makes the question confusing.



Otherwhise it was a good question though.
Post #793405
Posted Thursday, September 24, 2009 10:01 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, September 25, 2009 1:43 PM
Points: 4, Visits: 15
I almost answered No based on the example even though I use FROM in UPDATE statements all the time. I echo the earlier the suggestions that some questions are better off without a poorly written example.
Post #793407
Posted Thursday, September 24, 2009 10:43 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, September 23, 2014 7:06 AM
Points: 204, Visits: 203
I know that the intended database environment for this question was SQL Server so the answer is yes, however if running T-SQL against an Access database, the answer is no. To me technically, the correct answer is 'depends' yes. (Corrected) I just did the research and discovered that T-SQL is SQL Server specific. Access uses JET SQL. I maintain applications that can run against either sql server or access and share 95% of the sql statements. Update queries against joined tables is one area that I have to be specific to the target database.
Post #793429
Posted Thursday, September 24, 2009 11:30 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Monday, August 25, 2014 10:25 PM
Points: 698, Visits: 158

Yes
and we can use all the DML operation while updation
Post #793458
Posted Thursday, September 24, 2009 4:10 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, February 4, 2011 7:20 AM
Points: 977, Visits: 1,499
amit_adarsh (9/24/2009)

Yes
and we can use all the DML operation while updation


I think you meant to say updationing.


Tom Garth
Vertical Solutions

"There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers
Post #793604
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse