satanorz
July 18th, 2008, 06:33 AM
Hi all!, I've a SQL Express 2005 database that have many tables with AFTER INSERT/UPDATE triggers that does the same on all the tables.
Then, i've created an StoredProcedure to be called within these triggers.. so less repeteable code and an advantage on future changes..
The stored proc:
CREATE PROCEDURE [dbo].[sp_ControlarModificacion]
-- Add the parameters for the stored procedure here
@Tabla table,
@Clave int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
update @Tabla set FechaModificacion = GETDATE(), UsuarioModificacion = USER where clave = @clave
END
And the call from the trigger will be some like..
exec dbo.sp_ControlarModificacion inserted, @Clave
But i've a problem, SQL Server throw me the error "Incorrect syntax near the keyword 'table "when i try to save the stored procedure.
Some ideas? Thanks!
Then, i've created an StoredProcedure to be called within these triggers.. so less repeteable code and an advantage on future changes..
The stored proc:
CREATE PROCEDURE [dbo].[sp_ControlarModificacion]
-- Add the parameters for the stored procedure here
@Tabla table,
@Clave int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
update @Tabla set FechaModificacion = GETDATE(), UsuarioModificacion = USER where clave = @clave
END
And the call from the trigger will be some like..
exec dbo.sp_ControlarModificacion inserted, @Clave
But i've a problem, SQL Server throw me the error "Incorrect syntax near the keyword 'table "when i try to save the stored procedure.
Some ideas? Thanks!