Thanks for your input. You are right that your sample will not run with SQL Server 2000, even SQL Server 2005. I did test my simple query with my SQL Server 2008 instance and it works. Your sample can run too without problem. I need to search for more information
to make this more clear. I go ahead to edit my post with SQL server 2008 only.
My statement is within the context of scalar value in this question: "You cannot put two columns in your select top1 query." .
Ha, that's kool, I didn't know they changed this in SQL2K8, that's a very nice improvment, even though I pity the guys who wrote the parser for it ;-).
Hum... Who's choosing the right answer here?!? Whoever that is, that person really need to stop smoking whatever he's smoking because that must be not good for his healt. No wonder there's people with insanly high scores here.
People who marked thread are from MS online support. We as moderators do not regularly mark thread answer unless there is a request. If you feel something is not right for any threads, you can always to use the Report abuse button to report it to get someone's
attention. You can also post a question on the Feedback forum to address concern. How to mark an answer for a thread has been raised many times in that forum but you can still post your view on it. Here is the link to the Feedback forum:(http://forums.asp.net/AddPost.aspx?ForumID=188)
IMO it would be really nice to have option to mark replies as helpful and as answers with different credit for Help and answer. But IMO again your replies were very helpful in this thread.
Beware of bugs in the above code; I have only proved it correct, not tried it. (Donald Knuth)
limno
All-Star
117326 Points
8003 Posts
Moderator
MVP
Re: Subqueries are not allowed in this context. Only scalar expressions are allowed.
Nov 06, 2008 02:42 PM|LINK
Thanks for your input. You are right that your sample will not run with SQL Server 2000, even SQL Server 2005. I did test my simple query with my SQL Server 2008 instance and it works. Your sample can run too without problem. I need to search for more information to make this more clear. I go ahead to edit my post with SQL server 2008 only.
My statement is within the context of scalar value in this question: "You cannot put two columns in your select top1 query." .
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm
Nicolas Budu...
Member
76 Points
28 Posts
Re: Subqueries are not allowed in this context. Only scalar expressions are allowed.
Nov 06, 2008 02:51 PM|LINK
Ha, that's kool, I didn't know they changed this in SQL2K8, that's a very nice improvment, even though I pity the guys who wrote the parser for it ;-).
Have a nice day!
Nicolas Budu...
Member
76 Points
28 Posts
Re: Subqueries are not allowed in this context. Only scalar expressions are allowed.
Nov 12, 2008 02:50 PM|LINK
Hum... Who's choosing the right answer here?!? Whoever that is, that person really need to stop smoking whatever he's smoking because that must be not good for his healt. No wonder there's people with insanly high scores here.
limno
All-Star
117326 Points
8003 Posts
Moderator
MVP
Re: Subqueries are not allowed in this context. Only scalar expressions are allowed.
Nov 12, 2008 03:10 PM|LINK
People who marked thread are from MS online support. We as moderators do not regularly mark thread answer unless there is a request. If you feel something is not right for any threads, you can always to use the Report abuse button to report it to get someone's attention. You can also post a question on the Feedback forum to address concern. How to mark an answer for a thread has been raised many times in that forum but you can still post your view on it. Here is the link to the Feedback forum:(http://forums.asp.net/AddPost.aspx?ForumID=188)
Thanks.
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm
Naom
All-Star
36004 Points
7901 Posts
Re: Subqueries are not allowed in this context. Only scalar expressions are allowed.
Nov 12, 2008 03:18 PM|LINK
IMO it would be really nice to have option to mark replies as helpful and as answers with different credit for Help and answer. But IMO again your replies were very helpful in this thread.
(Donald Knuth)
Visit my blog
Microsoft Community Contributor 2011-12
massdriver
Member
20 Points
5 Posts
Re: Subqueries are not allowed in this context. Only scalar expressions are allowed.
Nov 12, 2008 11:19 PM|LINK
you can also do this:
INSERT INTO Table1 (x, x, x,x, x) SELECT TOP 1 x, Foo.y, x, xFROM Foo WHERE ID = @something)
Order by z