Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

t-sql 2008 r2 error message Expand / Collapse
Author
Message
Posted Sunday, January 27, 2013 9:13 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 6:45 PM
Points: 375, Visits: 442

This is the first time I am writing a trigger. I am getting the following error message on a sql server 2008 r2 database.

"Msg 102, Level 15, State 1, Procedure eRPT_Transaction_Audit, Line 15 Incorrect syntax near 'TRY'. I do not know what is wrong can you tell me what is wrong with the following sql:


USE DEV
GO
CREATE TRIGGER [dbo].[eRPT_Transaction_Audit] ON [dbo].[eRPT_Transaction_Tracking]
AFTER INSERT
AS

BEGIN
SET NOCOUNT ON;

BEGIN TRY
INSERT INTO [dbo].[eRPT_Transaction_Audit] (Package_name, Received_Date, Download_Date,
Acknowledge_Date, Response_Docs_Date, Error_Report_Date,
FDR_Report_Date, Close_Date, File_Location,Response_Code)
SELECT Package_name, Received_Date, Download_Date,
Acknowledge_Date, Response_Docs_Date, Error_Report_Date,
FDR_Report_Date, Close_Date, File_Location,Response_Code FROM INSERTED
END TRY

END
GO



also note in the trigger, I am not listing the identity key for the table
Post #1412134
Posted Sunday, January 27, 2013 1:35 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, September 18, 2014 7:56 AM
Points: 6,723, Visits: 8,462
there is no catch block in your trigger. Is that how you intend it ? If so, don't use the try.


Johan


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


"press F1 for solution", "press shift+F1 for urgent solution"


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me but most of the time this is me
Post #1412148
Posted Monday, January 28, 2013 7:48 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, September 19, 2014 2:34 PM
Points: 12,923, Visits: 12,342
Please don't cross post. direct all replies here. http://www.sqlservercentral.com/Forums/Topic1412099-392-1.aspx

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1412442
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse