Reputation: 3451
I wanted to set a variable in SQL by
SELECT @myVariable=myColumn FROM myTable WHERE ...
But by mistake I wrote it without @
SELECT myVariable=myColumn FROM myTable WHERE ...
It seems that it is valid, there isn't any error in syntax, although variable of course isn't set.
So what does such instruction exactly do?
Upvotes: 0
Views: 524
Reputation: 3130
You're right that it is valid syntax and it names the output column as myVariable
and populates the column with the content of myColumn
.
Upvotes: 0
Reputation: 16917
This sets myVariable
as an alias for myColumnn
. It's essentially the same as:
Select MyColumn As MyVariable
From MyTable
Where ...
Upvotes: 4