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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Instead Of Triiger failing

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-10-15 : 08:26:32
paul writes "I have created a view on 2 tables and then created the following trigger:

CREATE TRIGGER INSERTDATA ON [dbo].[View1]
INSTEAD OF INSERT
AS
DECLARE @displayname1 varchar(100), @displayname2 varchar(100), @newGUID uniqueidentifier
set @newGUID = (select newid())
set @displayname2 = (select displayname2 from inserted)
set @Displayname1 = (select displayname1 from inserted)
INSERT INTO Test2 (id, displayname2) values(@newGUID, @displayname2)
INSERT INTO test1 (Displayname1, test2ID) values(@displayname1, @newGUID)

However I keep getting a message saying unable to insert null into test2.id. If I run this in query analyser (manually setting the variables) then it works.

Many thanks in advance for any help"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-10-15 : 08:36:10
Your trigger does not handle multi row inserts.

Jay White
{0}
Go to Top of Page
   

- Advertisement -