SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Changing setting for first day of the week


Changing setting for first day of the week

Author
Message
matt.gyton
matt.gyton
Mr or Mrs. 500
Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)

Group: General Forum Members
Points: 540 Visits: 295
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
Dugi
Dugi
SSCarpal Tunnel
SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)

Group: General Forum Members
Points: 4790 Visits: 3511
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/
Dugi
Dugi
SSCarpal Tunnel
SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)

Group: General Forum Members
Points: 4790 Visits: 3511
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/
matt.gyton
matt.gyton
Mr or Mrs. 500
Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)

Group: General Forum Members
Points: 540 Visits: 295
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?
Lowell
Lowell
SSC Guru
SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)

Group: General Forum Members
Points: 73191 Visits: 40960
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
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
matt.gyton
matt.gyton
Mr or Mrs. 500
Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)

Group: General Forum Members
Points: 540 Visits: 295
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
Lowell
Lowell
SSC Guru
SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)SSC Guru (73K reputation)

Group: General Forum Members
Points: 73191 Visits: 40960
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
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
matt.gyton
matt.gyton
Mr or Mrs. 500
Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)

Group: General Forum Members
Points: 540 Visits: 295
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!!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search