August 21, 2005 at 9:04 pm
Hi,
I am trying to pass a table to a stored proc and can't get it to work. Basically I want something like this to work:
CREATE PROCEDURE dbo.ps_InsUpd
@insertedTable table,
@deletedTable table
AS
select * into #inserted from @insertedTable
select * into #deleted from @deletedTable
The tables are the special tables inserted and deleted from the trigger for for insert, update, delete. Can you provide me the syntax to do this?
Thanks,
Michael
August 21, 2005 at 9:19 pm
August 21, 2005 at 9:43 pm
No need for dynamic sql here.. why can't you do the job in the trigger?
August 23, 2005 at 6:41 pm
Remi,
Good question. The reason I want to move the tables to a Stored Proc is that I want one set of code that is invoked from multiple triggers for maintenance reasons.
August 23, 2005 at 7:47 pm
Reading SQL Server Books Online (BOL) for "CREATE PROCEDURE" states that...
"All data types, except the table data type, can be used as a parameter for a stored procedure"
I had the same issue. In the end I wrote my own T-SQL code generator (C# winform) that scripted the trigger generation and the audit tables based on user-selection of db, tables (etc).
August 23, 2005 at 9:22 pm
Does it have to be done at the same time of the update or can it be delayed a little? I'm thinking that you could flag the rows that need processing and having a jog firing every x minutes... or when needed to finish the job. Temp tables could also do the job, but I'd be worried of dead locks (or long waits because of locks).
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply