Sample Header Ad - 728x90

stored procedure runs fine in all sessions but one

1 vote
2 answers
1023 views
There are procedures that run fine manually but not in a job , or fails when run from an application , or not work in SSIS SQL task Mine works in all sessions but one. this is the code I am running - it calls a stored procedure that gets the trigger definition(s) and save it in a temp table. works fine and it is part of my automation work. IF OBJECT_ID('tempdb.dbo.#Jagannatha_sp_getTriggerDef') IS NOT NULL DROP TABLE #Jagannatha_sp_getTriggerDef CREATE TABLE #Jagannatha_sp_getTriggerDef ( DB sysname not null, parent_name nvarchar(600) not null, object_id int not null, trigger_name sysname not null, is_disabled bit, i int not null, [trigger_definition] NVARCHAR(MAX) not null, primary key clustered (DB,trigger_name,i)) truncate table #Jagannatha_sp_getTriggerDef exec sp_getTriggerDef @dbname = 'APCore', @TableName = 'dbo.receivedLog', @Drop_ONly = 0, @Radhe = '#Jagannatha_sp_getTriggerDef' SELECT * FROM #Jagannatha_sp_getTriggerDef order by db,i I run it on a table that has no triggers - just to make it as simple as possible enter image description here it comes out with the warning IF 'my_server\_DEVELOPMENT' @@ServerName THROW 50001, 'Wrong Server!!!',1 all good. but then on this particular session: enter image description here and there is nothing different in this session, that I could spot so far. SELECT * FROM sys.dm_exec_sessions where login_name = 'my_company\my_user' and session_id = @@SPID enter image description here the second one is where it fails. all others it works fine. what can I do to find out what is different? or even better, change the procedure so that it would work despite the difference?
Asked by Marcello Miorelli (17274 rep)
May 26, 2022, 07:13 AM
Last activity: Jul 7, 2022, 08:04 AM