December 5, 2016 at 3:09 pm
I have a job which runs SQL Script along with function which has started to run slow.
But when run the same query in the SSMS, it runs fine.
What could be the reason?
December 5, 2016 at 7:17 pm
PJ_SQL (12/5/2016)
I have a job which runs SQL Script along with function which has started to run slow.But when run the same query in the SSMS, it runs fine.
What could be the reason?
Could be any of a thousand reasons. Some of them could be quite simple. For example, does the job run at a different time of day than when you run it in SSMS?
--Jeff Moden
Change is inevitable... Change for the better is not.
December 6, 2016 at 7:04 pm
December 8, 2016 at 11:11 pm
This was removed by the editor as SPAM
December 9, 2016 at 7:39 am
MadAdmin (12/6/2016)
SET options.
I agree that this may be a good place to start. A common problem comparing a query running in Management Studio vs the same query run from a .Net connection or SQL Server Agent connection, is the arithabort setting.
SELECT client_interface_name, login_name, quoted_identifier, arithabort, ansi_null_dflt_on, ansi_defaults, ansi_warnings, ansi_padding, ansi_nulls, concat_null_yields_null, transaction_isolation_level FROM sys.dm_exec_sessions WHERE session_id = @@SPID
for Management Studio arithabort defaults to 1, but other connections default to 0. Microsoft says you should always use the ON or 1 setting:
https://msdn.microsoft.com/en-us/library/ms190306(v=sql.110).aspx
You can change the default connection settings at the instance level, (try it in a dev environment first of course)
in Management Studio Object Explorer, right click on the instance and select Properties. On the Connections page there is a Default connection options area, scroll down to arithmetic abort and check this checkbox. All future user connections will use that setting now unless they explicitly set it off.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply