Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Trigger Help

Author  Topic 

xrum
Yak Posting Veteran

87 Posts

Posted - 2011-03-08 : 14:56:34
HI,

this is what i have now:

GO
/****** Object: Trigger [dbo].[trg_SourceHistory] Script Date: 03/08/2011 14:38:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[trg_SourceHistory]
ON [dbo].[tblSource]
for UPDATE
AS
begin try
INSERT INTO tblHistorySource
select *, getdate()
from [DELETED]
end try
begin catch
SELECT
ERROR_NUMBER() AS ErrorNumber,
ERROR_SEVERITY() AS ErrorSeverity,
ERROR_STATE() AS ErrorState,
ERROR_PROCEDURE() AS ErrorProcedure,
ERROR_LINE() AS ErrorLine,
ERROR_MESSAGE() AS ErrorMessage;
RAISERROR('Error in Source Hisotry Trigger' ,16,1)
ROLLBACK TRAN
END CATCH


but i keep getting the following error: Insert Error: Column name or number of supplied values does not match table definition.

i was thinking that maybe it would be a good idea to write out all the fields in the trigger to make sure everythign matches up, but i can't seem to figure out the format to do so.

insert into tblHistorySource (value1, value2) values (value1, value2)

where do i put this???

Thank you in advance!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-08 : 15:32:17
Show us the DDL (CREATE TABLE statemnt) of tblHistorySource and tblSource.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2011-03-08 : 22:17:07
quote:

insert into tblHistorySource (value1, value2) values (value1, value2)

where do i put this???



INSERT INTO tblHistorySource(Column1,column2....,ColumnN,ColumnN+1)
Select Column1,column2....,ColumnN, gettdate()
from [DELETED]
Go to Top of Page
   

- Advertisement -