January 1, 2018 at 11:53 pm
Comments posted to this topic are about the item SET the results
January 2, 2018 at 12:39 am
new thing added in my database about "SET" statement
Manik
You cannot get to the top by sitting on your bottom.
January 2, 2018 at 1:46 am
Nice one, thanks Steve.
Personal preference to use SELECT to assign values to variables.
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
January 2, 2018 at 4:46 am
Oh silly me! I was so focused on the whole principle that order is not guaranteed without an ORDER BY clause that I didn’t notice the use of SET instead of SELECT. I’ll definitely need to pay attention to these more carefully!
Tricky one Steve, ya got me!
LinkedIn: https://www.linkedin.com/in/sqlrv
Website: https://www.sqlrv.com
January 2, 2018 at 6:20 am
Good Question.
I was thinking to myself that not enough information was provided about the table structure to answer - since there is no guaranteed order, but we know how the engine behaves. I totally missed the SET statement.
January 2, 2018 at 8:52 am
This was one that surprised me as well. I didn't realize there was that much difference between SET/SELECT.
January 2, 2018 at 9:27 am
Aaron N. Cutshall - Tuesday, January 2, 2018 4:46 AMOh silly me! I was so focused on the whole principle that order is not guaranteed without an ORDER BY clause that I didn’t notice the use of SET instead of SELECT. I’ll definitely need to pay attention to these more carefully!Tricky one Steve, ya got me!
Me 2, I was going down the 'its a heap, it has no imposed order on it' path.
January 2, 2018 at 9:41 am
ManicStar - Tuesday, January 2, 2018 9:27 AMAaron N. Cutshall - Tuesday, January 2, 2018 4:46 AMOh silly me! I was so focused on the whole principle that order is not guaranteed without an ORDER BY clause that I didn’t notice the use of SET instead of SELECT. I’ll definitely need to pay attention to these more carefully!Tricky one Steve, ya got me!Me 2, I was going down the 'its a heap, it has no imposed order on it' path.
+1 on that!
...
January 2, 2018 at 4:32 pm
Simple and nice - thanks, Steve!
January 2, 2018 at 10:15 pm
I'm glad I'm not the only one that missed the SET as I was thinking SELECT as well. Nice one Steve.
----------------------------------------------------
January 3, 2018 at 1:29 am
DECLARE @login VARCHAR(100);SET @login = c.FirstName
FROM dbo.Contacts AS c
--Incorrect syntax near the keyword 'FROM'.
SET @login = (SELECT c.FirstName
FROM dbo.Contacts AS c)
--Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
January 3, 2018 at 1:51 am
Carlo Romagnano - Wednesday, January 3, 2018 1:29 AMThe answer is a little confused!
The statement raises an error, because of incorrect syntax and not because of multiple values assignement. The following statements demonstrate this:DECLARE @login VARCHAR(100);
SET @login = c.FirstName
FROM dbo.Contacts AS c
--Incorrect syntax near the keyword 'FROM'.SET @login = (SELECT c.FirstName
FROM dbo.Contacts AS c)
--Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Well spotted, Carlo
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
January 4, 2018 at 8:09 am
Thanks for this very instructive question!
Happy new year,
webrunner
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
January 4, 2018 at 9:19 pm
Aaron N. Cutshall - Tuesday, January 2, 2018 4:46 AMOh silly me! I was so focused on the whole principle that order is not guaranteed without an ORDER BY clause that I didn’t notice the use of SET instead of SELECT. I’ll definitely need to pay attention to these more carefully!Tricky one Steve, ya got me!
Same here. And I knew the right answer if I had just slowed down.
January 4, 2018 at 9:22 pm
At least, it's reassuring that I wasn't the only one that made that error.
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy