Skip to content
Advertisement

What is mean name after variable name in t-sql

I have the next query:

Сan you please explain what it means instruction:

Is a variable called startdate assigned a different name? But why?

Advertisement

Answer

First, I would write this as:

The two are equivalent, but this is clearer in intent (and less likely to cause problems).

In any case, @startdate is not a valid column name in a table — or CTE. So, you want to give it a valid name. That is what this is doing.

If you don’t give it a name, you will get an error, as illustrated here.

You should also use standard date formats, so I would suggest:

or:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement