July 31, 2008 at 2:06 am
Is there a way to run
EXEC ('Select * INTO #INS From INSERTED') in trigger?
OR
Is there a way to execute this query?
Declare @columns varchar(200)
SET @columns= 'stID, stName, stAddress'
Select @columns INTO #INS From INSERTED
Regards,
Shahbaz
July 31, 2008 at 2:12 am
Is there a way to run
EXEC ('Select * INTO #INS From INSERTED') in trigger?
I think SELECT INTO command not allowed within a trigger.
karthik
July 31, 2008 at 2:17 am
SELECT * INTO #INS FROM INSERTED
it works fine.
I just want to run this query via EXEC command.
July 31, 2008 at 2:20 am
Could you explain a bit more what you're trying to achieve here please?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 31, 2008 at 2:23 am
shahbaz_awan (7/31/2008)
SELECT * INTO #INS FROM INSERTEDit works fine.
I just want to run this query via EXEC command.
You can do it, but the scoping rules around Temp Tables means that the temp table will only exist for the duration of the EXEC and won't be visible in the trigger or anywhere outside of that.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 31, 2008 at 2:33 am
As you know that INSERTED and DELETED tables do not retrieve the values of text, ntext and image types, and I want to make a generic procedure to create one trigger on all tables, so there are some tables with text, ntext and image data type, I want to exclude these columns by assigning them in a variables so that I can run my query. it fit with permanent tables but with INSERTED or DELETED tables it is not working.
I have other way to exlcude the tables with text,ntext and image data types and create triggers individually for these tables,
But plz let me know if there is any way.
Regards,
Shahbaz
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply