Sankalpa Nirmana Sankalpa Nirmana - 1 year ago 132
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

Answer Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download