Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Changing setting for first day of the week Expand / Collapse
Author
Message
Posted Monday, October 22, 2012 5:16 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Today @ 9:37 AM
Points: 76, Visits: 232
Hi there,

I am having some trouble with some SQL Job schedules because I believe SQL is using Sunday as the first day of the week by default. I have separate jobs for each weekend which must run Friday, Saturday, Sunday consecutively. Unfortunately, as SQL considers Sunday the first day of the week, they are running first on the Sunday and then the following Friday and Saturday. Is there a way to change the setting for the first day of the week?

So, effectively I would be looking to go from this:

1 - Sunday
2 - Monday
3 - Tuesday
4 - Wednesday
5 - Thursday
6 - Friday
7 - Saturday

...to this...

1 - Monday
2 - Tuesday
3 - Wednesday
4 - Thursday
5 - Friday
6 - Saturday
7 - Sunday

Any ideas? I'm also not sure if changing this could affect anything else other than for SQL Jobs?

Thanks
Post #1375345
Posted Monday, October 22, 2012 5:36 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, August 27, 2014 1:51 AM
Points: 1,262, Visits: 3,422
Did you try:

SET DATEFIRST 1;
GO

Check the first date with

SELECT @@DATEFIRST


============================================================
SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1375350
Posted Monday, October 22, 2012 5:44 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, August 27, 2014 1:51 AM
Points: 1,262, Visits: 3,422
Also I don't know which language you are using, however you can change the language for the user like:

Check the language that has the first date Monday... more correct check the value of the DateFirs col, that is third col in your results. is it 1!
SELECT * FROM sys.syslanguages


Then, now try to change the language of the user that you've created to run schedule jobs, like this:

USE [master]
GO
ALTER LOGIN [user] WITH DEFAULT_LANGUAGE = "Your language that you have choose to be from syslanguages"
GO

Sample:
USE [master]
GO
ALTER LOGIN [YourUserName] WITH DEFAULT_LANGUAGE = [Deutsch]
GO


============================================================
SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1375355
Posted Monday, October 22, 2012 6:07 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Today @ 9:37 AM
Points: 76, Visits: 232
Thanks Dugi - that looks good!

Currently the jobs just run under the domain account that runs the SQL Agent Services, although this account is not listed under the Logins in SSMS. There is a login called 'NT SERVICE\SQLSERVERAGENT' though - is this what needs changing? Or do I need to add the domain service account to the logins and set the language for that?
Post #1375364
Posted Monday, October 22, 2012 6:10 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:20 AM
Points: 12,916, Visits: 32,080
those set options are connection specific; they are not server wide.
just because you set it someplace, does not mean it's going to affect jobs or anything else on the server.

each job would need to be edited to have new set options.

if you are connecting with , say .NET, you need to set the options there.
SSMS has a place where you can change most of those settings via the GUI , and every ODBC driver has the ability to set them as well.


Note that even if you could set these items server wide, they would be over-riden by the connections settings themselves.



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1375365
Posted Monday, October 22, 2012 6:57 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Today @ 9:37 AM
Points: 76, Visits: 232
Hi Lowell,

These are just standard SQL Agent Jobs being run on a schedule, so I'm assuming I could just change the default language setting for the login they are being run under (currently the SQL Agent Service account)?

Would changing the default language for 'NT SERVICE\SQLSERVERAGENT' do this?

Thanks
Post #1375401
Posted Monday, October 22, 2012 7:09 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:20 AM
Points: 12,916, Visits: 32,080
matt.gyton (10/22/2012)
Hi Lowell,

These are just standard SQL Agent Jobs being run on a schedule, so I'm assuming I could just change the default language setting for the login they are being run under (currently the SQL Agent Service account)?

Would changing the default language for 'NT SERVICE\SQLSERVERAGENT' do this?

Thanks


i think so yes, but you'd have to test it. it would be better to change whatever script you are using to not be sensuitive to datefirst instead;

can you explain what is not running or occuring correctly because of that setting?


Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1375407
Posted Monday, October 22, 2012 7:27 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Today @ 9:37 AM
Points: 76, Visits: 232
Lowell (10/22/2012)
matt.gyton (10/22/2012)
Hi Lowell,

These are just standard SQL Agent Jobs being run on a schedule, so I'm assuming I could just change the default language setting for the login they are being run under (currently the SQL Agent Service account)?

Would changing the default language for 'NT SERVICE\SQLSERVERAGENT' do this?

Thanks


i think so yes, but you'd have to test it. it would be better to change whatever script you are using to not be sensuitive to datefirst instead;

can you explain what is not running or occuring correctly because of that setting?


Basically each Job runs a windows CmdExec command, which kicks off a Netbackup procedure. There are 4 jobs, Weekly1, Weekly2, Weekly3 and Monthly. Each weekend, one of these jobs must be run consecutively on the Friday, Saturday and Sunday as follows:

Week 1: Weekly1 runs Friday, Saturday and Sunday.
Week 2: Weekly2 runs Friday, Saturday and Sunday.
Week 3: Weekly3 runs Friday, Saturday and Sunday.
Week 4: Monthly runs Friday, Saturday and Sunday.

The problem is that because SQL considers Sunday the first day of the week, the Friday and Saturday are considered to be part of one week, but the Sunday is part of the next week, so instead of running on consecutive days they run as follows:

Week 1: Weekly1 runs Sunday......Friday, Saturday.
Week 2: Weekly2 runs Sunday......Friday, Saturday.
Week 3: Weekly3 runs Sunday......Friday, Saturday.
Week 4: Monthly runs Sunday......Friday, Saturday.

Hope that makes sense!!
Post #1375419
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse