Sankalpa Nirmana Sankalpa Nirmana - 5 months ago 23
SQL Question

Select statement MSSQL

This is my function FirstDayInQtr

This is the sql query

SELECT @day = DATEADD(qq, DATEDIFF(qq ,0, @InputDate),0)


who can explain this statement

MK_ MK_
Answer

I believe this will clear your uncertainties: http://stackoverflow.com/a/3945396/6492765

Basically, SELECT is a T-SQL way of setting a value for a variable, the magic being in selecting from joins or other select concepts directly into variables. With assigning 1 value to only 1 variable, it does not differ from SET which, in your case, would be:

SET @day = DATEADD(qq, DATEDIFF(qq ,0, @InputDate),0)
Comments