title: SQL Server SET DATEFIRST scope
body: <p>I'm using SS 2005 if that</p>
  
  <p>I've seen sample code like</p>
  
  <pre><code>DECLARE @restore = SELECT @@DATEFIRST
  SET DATEFIRST 1
  SELECT datepart(dw,ADateTimeColumn) as MondayBasedDate,.... FROM famousShipwrecks --
  SET DATEFIRST @restore
  </code></pre>
  
  <p>Suppose while the query is running another query sets DATEFIRST?</p>
  
  <p>If another query relies on datefirst being 7 (for example) and doesn't set it, and runs while my query is running, that's his problem for not setting it?  or is there a better way to write queries that depend on a given day being day number 1.</p>