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 2008 Forums
 Other SQL Server 2008 Topics
 trigger

Author  Topic 

nord
Posting Yak Master

126 Posts

Posted - 2012-01-23 : 14:53:18
Hi,i have trigger,how i can run this:


ALTER TRIGGER [dbo].[TR_OBTU_PoHeader] on [dbo].[po_header]
error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'on'.
thanks

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-01-23 : 15:21:35
Are you trying to alter the trigger, or run the trigger code? If you are trying to alter it, you need to add information on what kind of trigger (update, insert etc.) and the trigger body. See documentation and examples here: http://msdn.microsoft.com/en-us/library/ms189799.aspx

If you want to execute the trigger code: Normally, you don't. You perform the action (update, insert etc.) and the trigger code gets called by SQL Server.
Go to Top of Page

nord
Posting Yak Master

126 Posts

Posted - 2012-01-23 : 15:31:32
hi,i modify trigger and i wand to know if trigger is work,how i do it?
thanks
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-01-23 : 15:43:56
You can insert/update/delete from the [dbo].[po_header] and observe whether the action you requested within the trigger has happened via select queries etc. If you just want to see if the trigger gets called, you could put a print statement. Here is an example:
-- A Table
CREATE TABLE dbo.MyT1( id INT );
GO

-- A trigger on it.
CREATE TRIGGER dbo.MyT1Trigger ON dbo.MyT1
FOR INSERT
AS PRINT 'In the trigger';
GO

-- Insert a row.
INSERT INTO MyT1 VALUES (1);
-- the print statement should show up in the messages are in SSMS.
Go to Top of Page

nord
Posting Yak Master

126 Posts

Posted - 2012-01-24 : 08:25:01
Thanks
Go to Top of Page
   

- Advertisement -