January 15, 2017 at 8:06 am
Comments posted to this topic are about the item DECLARE multiple vars with default value
God is real, unless declared integer.
January 15, 2017 at 11:01 am
Just so people don't get confused, the question was about what happens when you try to make a cascading assignment using DECLARE. The same does NOT hold true for making cascading assignments with SELECT. For example, the following does work...
DECLARE @s VARCHAR(5),
@t VARCHAR(5)
;
SELECT @s = 'test',
@t = @s
;
PRINT @t
;
--Jeff Moden
Change is inevitable... Change for the better is not.
January 16, 2017 at 12:48 am
This was removed by the editor as SPAM
January 16, 2017 at 1:12 am
t.franz - Sunday, January 15, 2017 8:06 AMComments posted to this topic are about the item DECLARE multiple vars with default value
For the sake of completeness: In Jeff Modens example (first declare the variables and then SELECT @s-2='test', @t=@s) @t would contain the value 'test' (the variables will be set in the same order as they occur in the SELECT statement).
God is real, unless declared integer.
January 16, 2017 at 6:03 am
Back to basics, thanks for the question.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle
January 16, 2017 at 4:47 pm
t.franz - Monday, January 16, 2017 1:12 AMt.franz - Sunday, January 15, 2017 8:06 AMComments posted to this topic are about the item DECLARE multiple vars with default valueFor the sake of completeness: In Jeff Modens example (first declare the variables and then SELECT @s-2='test', @t=@s) @t would contain the value 'test' (the variables will be set in the same order as they occur in the SELECT statement).
For the sake of completeness, I was hoping that people would actually run the code. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
February 27, 2017 at 4:15 pm
Nice basics question.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply