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.
Author |
Topic |
swetsri
Starting Member
1 Post |
Posted - 2008-05-31 : 13:59:39
|
Hi all I've Created a Trigger statement and tried to execute this using ExecuteNonQuery.but it shows the following errorIncorrect syntax near 'GO'.'CREATE TRIGGER' must be the first statement in a query batch. if i start with Create Trigger statement it show "Incorrect Syntax near Create Trigger".the following is the trigger statement which i've generated in C# Can anyone help me?thanks in advancesriIF EXISTS (SELECT name FROM sysobjects WHERE name = 'SampleTrigger' AND type = 'TR')DROP TRIGGER SampleTriggerGOCREATE TRIGGER SampleTriggerON dbo.sampleAFTER INSERTAS beginSET NOCOUNT ONDECLARE @RID as intDECLARE @email AS nvarchar(50)SELECT @email= i.email from inserted iDECLARE @Name AS nvarchar(50)SELECT @Name= i.Name from inserted iDECLARE @Address AS nvarchar(50)SELECT @Address= i.Address from inserted iinsert into Register(ServerName,DatabaseName,TableName) values('Sample','SamDatabase','SamTable')SELECT @RID = @@Identityinsert into TableFields(RID,FieldName,FieldValue) values(@RID ,'Name',@Name)insert into TableFields(RID,FieldName,FieldValue) values(@RID ,'Address',@Address)insert into TableFields(RID,FieldName,FieldValue) values(@RID ,'email',@email)end |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
|
|
|
|
|
|