Quantcast
Channel: CodeFari
Viewing all articles
Browse latest Browse all 265

What is the difference between DATEFIRST and @@DATEFIRST in SQL Server

$
0
0
DATEFIRST keyword use to reset first day of week in SQL Server and @@DATEFIRST return the current value for the session of DATEFIRST.

For Example:-
As we know SQL Server set default language US English and SQL Server sets by default DATEFIRST to 7 (Sunday).

SETDATEFIRST 6
If we execute above query it will set Saturday as the first day of week.
@@DATEFIRST will returns the current value of SET DATEFIRST for the session.

SETLANGUAGEfrench
GO
SELECT@@DATEFIRST
GO
--result will return 1 (Monday)

SETLANGUAGEus_english
GO
SELECT@@DATEFIRST
GO
--result will return 7 (Sunday)

Viewing all articles
Browse latest Browse all 265

Trending Articles