July 11, 2011 at 1:25 pm
Hi Guys,
CREATE TRIGGER [dbo].[Insert_Data_Tri_st_ppl] on [dbo].[st_ppl]
FOR INSERT
AS
BEGIN
IF(NOT EXISTS(select p.st_cd from st_cd p, inserted i where p.st_cd = i.st_cd))
INSERT into st_cd select * from inserted
END
--When i try to create trigger i get the below error message.Let me know what i am missing?
Msg 213, Level 16, State 1, Procedure Insert_Data_Tri_st_ppl, Line 6
Column name or number of supplied values does not match table definition.
Thanks
Admin
July 11, 2011 at 1:31 pm
Check your table definitions - st_ppl and st_cd will need to have the same columns in the same order. Otherwise, don't use * in your insert...select statement. Instead name the columns for each.
July 11, 2011 at 1:35 pm
The trigger is created on [st_ppl] therefore the inserted table will look exactly like st_ppl , you need to make sure the column and data types of your destination table match that of st_ppl in order to insert the data, explicitly select each column from the inserted table to make the query more readable.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply