January 27, 2013 at 9:13 am
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
January 27, 2013 at 1:35 pm
there is no catch block in your trigger. Is that how you intend it ? If so, don't use the try.
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- 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
January 28, 2013 at 7:48 am
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply