|
Comments
|
|
As you mentioned in this video, when setting large lists of variables it's better to use the select method to assign values to variables. Our company has seen some significant performance improvements at least with that aspect of the content seen here. Thanks for sharing! Great info.
|
|
|
good to know the methods are similar and inter-chagable.
|
|
|
nice info but maybe you could have gone a bit further and do some if/else logic with the result. If you get no values, you are probably comparing null and that's a special case, right?
|
|
|
There is an advantage to using the SET @Variable = (SELECT...). If the SELECT returns multiple rows, the SET statement will throw a 512 error. So if identical code leads to ambiguity later because of a schema change, that method will detect it due to the subquery error.
|
|
|
The video ignored the situation where you need to capture multiple pieces of information such as Rowcount and error id after a SQL statement.
|
|
|
Really like the video series, short snippets, easy to digest.
|
|
|
sql was hard to see.
|
|
|
not very useful , at least i was excepting a benchmark (single loads , parallels loads) to compare (as the title says 'Vs') the efficiency on multiple assignment, big variables,etc.. I did not learn a thing here..
if you do not have time to do the benchmark, at least you could explain that with select we can do iteration...like for example
declare @test varchar(max) = ''
select top 10 @test = (case @test when '' then EmailAdress else @test + '|' + EmailAdress end) from person.contact
print @test
Have a good day
|
|
|
Always good to review the basics no matter how experienced you are.
|
|
|
Relax guys there is only so much you can cram in a 5 minute video. I think this video was very informative as it showed how SET and SELECT were different and alike. The title never mentioned doing benchmark comparisons.
|
|
|
The screen is slightly blurred, otherwise I would have given a 5!
|
|
|
no video
|
|
|
Thanks for the comments everyone, I'll continue to try to get as much into a lesson as I can, it's hard to know when the bucket is too full or not full enough sometimes.
|
|
|
Nice video. i like it. Thanks
|
|
Gabriel Dunn on
10/6/2010
So you think 'SET' is more readable in the first half, but 'SELECT' is more readable in the 2nd half ?
I think SET is more intuitive that a variable is being modified. SELECT is so often used when viewing records that it's not immediately obviouse a valuse is changing.
|
|
Carla Wilson on
10/6/2010
Are there ways to break the syntax? like:
set @Firstname = 'x', @Lastname = 'y'?
|
|
|
I see these all the time and don't know what technique is the best. Good topic!
|
|
Pradeep Ranjan on
10/20/2010
While assigning multiple variables you need to write n no of SET statements for n no of variables. But it can be achieved in one go with SELECT.
e.g.
DECLARE @A VARCHAR(2), @B VARCHAR(2)
SET @A = 1, @B = 2
SELECT @A, @B
Above code will through an exception... (comma)
What you need to do is...
SET @A = 1
SET @B = 2
Now with Select
DECLARE @A VARCHAR(2), @B VARCHAR(2)
SELECT @A = 1, @B = 2
SELECT @A, @B
It is perfectly work.
It is totally depends on the situation, means what we want to assign and how many variables are there.
|
|
|
This was very helpful having coming from a background in Oracle SQL
|
|
|
It's a personal approach
|