June 5, 2009 at 3:12 pm
GilaMonster (6/5/2009)
Lynn Pettis (6/5/2009)
GilaMonster (6/5/2009)
Lynn Pettis (6/5/2009)
Here is another OMG moment.He may have just misunderstood what BoL was. I'd be a little unhappy if I asked a simple question and was told to go buy a book. Let's see how he responds.
Partial points for this answer. I'll bite that maybe he didn't understand what Books Online is, but I NEVER used the word BUY or phrase BUY THE BOOK. 😉
No, but if he assumed you were telling him to go read a book that he thought he didn't have....
That's why I am giving you partial points on this one. What I am thinking of doing in the future when I suggest to OP's to read Books Online is to add an additional statement that this is the SQL Server Help file that comes with SQL Server. This way, they shouldn't become confused. :w00t:
June 5, 2009 at 3:17 pm
Lynn Pettis (6/5/2009)
What I am thinking of doing in the future when I suggest to OP's to read Books Online is to add an additional statement that this is the SQL Server Help file that comes with SQL Server. This way, they shouldn't become confused. :w00t:
For guys that sound really new that's a good idea, that or give them a link to the online version of BoL. Probably wouldn't do it for everyone.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 5, 2009 at 3:20 pm
GilaMonster (6/5/2009)
Lynn Pettis (6/5/2009)
What I am thinking of doing in the future when I suggest to OP's to read Books Online is to add an additional statement that this is the SQL Server Help file that comes with SQL Server. This way, they shouldn't become confused. :w00t:For guys that sound really new that's a good idea, that or give them a link to the online version of BoL. Probably wouldn't do it for everyone.
That sounds like a better plan. Of course, it also means putting the url for the online version somewhere handy so I get it easily. I just use my local copy of BOL when I need it.
😉
June 5, 2009 at 3:39 pm
That's why I always spell it out the first time that I am responding to someone I haven't seen before, like "...BOL(Books Online)...", though now I am thinking that that may not be enough either.
(Believe it or not, the first time I cam to this site, it took me a day to figure out what this "BOL" was that everyone kept talking about. And SSMS? What was that and when did it come out? 🙂 ).
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
June 5, 2009 at 3:43 pm
The first time I mentioned BOL I did spell it out, but I didn't put the TLA along with it. You'll see that if you look at my post just above where I use the TLA BOL.
😛
June 5, 2009 at 3:44 pm
Lynn Pettis (6/5/2009)
GilaMonster (6/5/2009)
Lynn Pettis (6/5/2009)
What I am thinking of doing in the future when I suggest to OP's to read Books Online is to add an additional statement that this is the SQL Server Help file that comes with SQL Server. This way, they shouldn't become confused. :w00t:For guys that sound really new that's a good idea, that or give them a link to the online version of BoL. Probably wouldn't do it for everyone.
That sounds like a better plan. Of course, it also means putting the url for the online version somewhere handy so I get it easily. I just use my local copy of BOL when I need it.
😉
Hopefully they installed it when they installed the server. You could always tell them to press the {f1} function key to get to it.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 5, 2009 at 5:24 pm
Lynn Pettis (6/5/2009)
Here is another OMG moment.
Lynn, I see yet once again why we refer to you as Saint.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
June 6, 2009 at 7:01 am
You know, it's always those complex T-SQL concepts that trip up so many people.
Good going Gail!
Edit: fixed link
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
June 6, 2009 at 7:06 am
WayneS (6/6/2009)
You know, it's always those complex T-SQL concepts that trip up so many people.Good going Gail!
Hi Wayne,
your link doesn't work (double referenced).
June 6, 2009 at 7:12 am
Lynn Pettis (6/5/2009)
GilaMonster (6/5/2009)
Lynn Pettis (6/5/2009)
What I am thinking of doing in the future when I suggest to OP's to read Books Online is to add an additional statement that this is the SQL Server Help file that comes with SQL Server. This way, they shouldn't become confused. :w00t:For guys that sound really new that's a good idea, that or give them a link to the online version of BoL. Probably wouldn't do it for everyone.
That sounds like a better plan. Of course, it also means putting the url for the online version somewhere handy so I get it easily.
I've got a firefox extension called "Clippings". I have a fair few 'standard' replies and urls in there. Other alternative, stick it as a bookmark. In firefox if I drag a bookmark to a text box, the url of that bookmark is pasted in. Don't know about IE.Please post in the appropriate forum in the future.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 6, 2009 at 7:16 am
WayneS (6/6/2009)
You know, it's always those complex T-SQL concepts that trip up so many people.Good going Gail!
I know. Those darned updates are just so hard to understand. :hehe:
Correct link - http://www.sqlservercentral.com/Forums/FindPost730218.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 6, 2009 at 7:43 am
Regarding the update of the table variable.
Let me start by saying that the poster's comments grated with me too...especially considering the first post was incomplete and contained errors.
Having said all that, I do have some sympathy. And not just because of the (presumed) language barrier.
The requirement to alias a table variable for UPDATE is not spectacularly well documented in BOL. A quick skim over the entry for the UPDATE statement revealed nothing to me - I may have missed it, but I don't think so. It is logical once you think about it, but I don't think it is obvious.
I think it is quite natural that someone would expect to write UPDATE @t SET ... or even UPDATE @t AS T SET ...
UPDATE T SET ... FROM @t AS T is quite odd-looking, at least to me. (Ok so a join was required in this case anyway so the FROM was needed in any case)
I think I am right in saying that Gail's post originally had UPDATE t SET ... FROM @t t... so it was perhaps forgivable to miss the alias. This is one reason I personally prefer to always include the optional 'AS'. To me, ...FROM @t AS t... is clearer somehow.
Oh and hey, no criticisms intended, just adding my take on the wider point.
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
June 6, 2009 at 7:48 am
I see mjarsaniya has posted a very apologetic reply.
Good on him/her. It would have been easy to take the solution and run.
Nice to see.
http://www.sqlservercentral.com/Forums/FindPost730229.aspx
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
June 6, 2009 at 8:20 am
Paul White (6/6/2009)
Having said all that, I do have some sympathy. And not just because of the (presumed) language barrier.The requirement to alias a table variable for UPDATE is not spectacularly well documented in BOL. A quick skim over the entry for the UPDATE statement revealed nothing to me - I may have missed it, but I don't think so. It is logical once you think about it, but I don't think it is obvious.
Yes it does look weird, and I'd have understood fully if he said he didn't understand or wasn't sure why it worked. Having people tell me that my code doesn't work when it's clear that they haven't even tried it irritates me. Especially since I had tested it cause I'm never quite sure of the update syntax myself (keep forgetting if it's UPDATE TableName or UPDATE TableAlias). That's what grated for me, not the lack of understanding.
You didn't find the syntax under UPDATE, because it's somewhere else and it's impact on the UPDATE statement has to be inferred. Specifically on the page detailing the table data type. (Yup, first place I'd have looked for it, not)
ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_6tsql/html/1ef0b60e-a64c-4e97-847b-67930e3973ef.htm
Outside a FROM clause, table variables must be referenced by using an alias, as shown in the following example:
SELECT EmployeeID, DepartmentID
FROM @MyTableVar m
JOIN Employee on (m.EmployeeID =Employee.EmployeeID AND
m.DepartmentID = Employee.DepartmentID)
The only thing the Update page states is
A table variable, within its scope, can be used as a table source in an UPDATE statement.
Table source defined as a table appearing after the FROM in the update statement. Though from that alone, I could easily assume it's not possible to update a table variable at all.
Doesn't help that none of the examples use an alias and it doesn't say anywhere that aliases can be used in the UPDATE. Though I do have an older copy of BoL. Think I might submit request for enhancements on that page.
I think I am right in saying that Gail's post originally had UPDATE t SET ... FROM @t t... so it was perhaps forgivable to miss the alias. This is one reason I personally prefer to always include the optional 'AS'. To me, ...FROM @t AS t... is clearer somehow.
It did. My habit is to use AS on column aliases but to omit it on table aliases. It's just how I code.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 6, 2009 at 8:24 am
lmu92 (6/6/2009)
WayneS (6/6/2009)
You know, it's always those complex T-SQL concepts that trip up so many people.Good going Gail!
Hi Wayne,
your link doesn't work (double referenced).
Thanks, I fixed it.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 15 posts - 5,416 through 5,430 (of 66,712 total)
You must be logged in to reply to this topic. Login to reply