Sankalpa Nirmana Sankalpa Nirmana - 3 months ago 6x
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


I believe this will clear your uncertainties:

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)