September 23, 2024 at 8:40 am
Hi
I have a little big problem.
I have a job that uses the Weekday for calculate the two year change hour days.
When I execute the procedure in management studio the result of Monday shows the number 7 of weekday, when execute with SQL SERVER Agent, Monday show day 1 of weekday. I check the two windows users, mine and the windows user (I created a windows user that run the SQL Server and SQL Server Agent services), an all are configured that Monday is first day of week. All region and dateformats are the same.
Someone knows where are the "config flag" for this?
Actually I executed first the SET DATEFIRST, for jump this problem, but I want to know where is the correct configuration.
Thanks a lot to all.
Jorge
September 24, 2024 at 9:10 am
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
September 24, 2024 at 5:40 pm
I think it's based on the default language for the login which can differ from the instance default language.
If the default is us_english then datefirst = 7 but most European countries have datefirst =1.
select *
from sys.syslanguages
I found this query that I think shows the default language for logins, but I could be wrong.
Perhaps the account that sql agent is running under has a different setting.
select [name], [type_desc],
default_language_name,default_database_name
from sys.server_principals
where [type] not in ('R','C')
September 25, 2024 at 10:36 am
Hi,
All the logins are SQL Server login. With the same user. SQL Server and SQL Server Agent services are initiated by same Windows user.
The only diference is run procedure directly from SQL Server Management Studio or run JOB in Agent.
At this moment I updated all procedures with SET DATEFIRST
September 25, 2024 at 10:37 am
Wait a moment. I don't know what user uses SQL Server Agent by default... .is possible this is the problem...
September 25, 2024 at 3:39 pm
SELECT servicename, service_account
FROM sys.dm_server_services;
September 27, 2024 at 3:26 am
If you would post the code you're using, perhaps we could solve all of your problems with a bit of a magic temporal formula that doesn't rely on any settings whatsoever.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 28, 2024 at 6:38 am
This was removed by the editor as SPAM
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply