Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSIS: Custom Logging Using Event Handlers


SSIS: Custom Logging Using Event Handlers

Author
Message
ronan.healy
ronan.healy
SSC-Enthusiastic
SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)

Group: General Forum Members
Points: 136 Visits: 232
hi
im trying to create an event lof for when thinks fail in my ssis package
im using the following code

INSERT INTO [dbo].[SSISLog]
([EventType]
,[PackageName]
,[TaskName]
,[EventCode]
,[EventDescription]
,[PackageDuration]
,[ContainerDuration]
,[InsertCount]
,[UpdateCount]
,[DeleteCount]
,[Host])

VALUES
(
'OnPostExecute',
'"+@[System:TongueackageName]+"',
'"+@[System::TaskName]+"',
0,
'"+@[System::SourceDescription]+"',
"+ (DT_STR, 6, 1252)DATEDIFF("ss", @[System::StartTime] , GETDATE() ) + ",
"+ (DT_STR, 6, 1252)DATEDIFF("ss", @[System::ContainerStartTime] , GETDATE() ) + ",
411,
2,
12,
'"+ @[System::MachineName] +"'
)



getting the following error
Msg 102, Level 15, State 1, Line 21
Incorrect syntax near 'ss'

anyone any ideas
John Mitchell-245523
John Mitchell-245523
SSCertifiable
SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)

Group: General Forum Members
Points: 7466 Visits: 15142
You're muddling up your single and double quotes. Use single quotes (') when quoting something in T-SQL, and double quotes (") when quoting something in an SSIS expression.

John
ronan.healy
ronan.healy
SSC-Enthusiastic
SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)

Group: General Forum Members
Points: 136 Visits: 232
hi
thanks for reply it will be going into an ssis package
so does it go in like this

INSERT INTO [dbo].[SSISLog]
([EventType]
,[PackageName]
,[TaskName]
,[EventCode]
,[EventDescription]
,[PackageDuration]
,[ContainerDuration]
,[InsertCount]
,[UpdateCount]
,[DeleteCount]
,[Host])

VALUES
(
'OnPostExecute',
"+@[System:TongueackageName]+",
"+@[System::TaskName]+",
0,
"+@[System::SourceDescription]+",
"+ (DT_STR, 6, 1252)DATEDIFF("ss", @[System::StartTime] , GETDATE() ) + ",
"+ (DT_STR, 6, 1252)DATEDIFF("ss", @[System::ContainerStartTime] , GETDATE() ) + ",
411,
2,
12,
"+ @[System::MachineName] +"
)


dave-dj
dave-dj
SSC-Addicted
SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)SSC-Addicted (438 reputation)

Group: General Forum Members
Points: 438 Visits: 1149
Just to add to that, you will need to escape the singal quote, with a single quote.

e.g.


declare @statement varchar(100)
set @statement = 'select ''DAY NO.: '' + CAST(DATEPART(DAY,getdate()) AS VARCHAR(2))'
execUTE( @statement)


where you to write the actual sql it would be:

[code="plain"][/code]select 'DAY NO.: ' + CAST(DATEPART(DAY,getdate()) AS VARCHAR(2))

_____________________________________________________________________________
MCITP: Business Intelligence Developer (2005)
ronan.healy
ronan.healy
SSC-Enthusiastic
SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)

Group: General Forum Members
Points: 136 Visits: 232
keep getting this error
[Execute SQL Task] Error: Executing the query "INSERT INTO [dbo].[SSISLog]
([EventType..." failed with the following error: "Conversion failed when converting the varchar value '+ (DT_STR, 6, 1252)DATEDIFF("ss", @[System::StartTime] , GETDATE() ) + ' to data type int.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
John Mitchell-245523
John Mitchell-245523
SSCertifiable
SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)

Group: General Forum Members
Points: 7466 Visits: 15142
ronan.healy (7/2/2013)
hi
thanks for reply it will be going into an ssis package
so does it go in like this

No. You need to wrap all non-numeric items in your INSERT statement in single quotes - something like this:

...
VALUES
(
'OnPostExecute',
'"+@[System:TongueackageName]+"',
...



If you don't intend those double quotes to be part of what's inserted into the table, just leave them out.

John
ronan.healy
ronan.healy
SSC-Enthusiastic
SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)

Group: General Forum Members
Points: 136 Visits: 232
ya have it like that in my ssis package and get the same error
[Execute SQL Task] Error: Executing the query "INSERT INTO [dbo].[SSISLog]
([EventType..." failed with the following error: "Conversion failed when converting the varchar value '"+ (DT_STR, 6, 1252)DATEDIFF("ss", @[System::StartTime] , GETDATE() ) + "' to data type int.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
John Mitchell-245523
John Mitchell-245523
SSCertifiable
SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)

Group: General Forum Members
Points: 7466 Visits: 15142
I don't understand. If that's how it is in your package, what was it you posted earlier?

You need the single quotes on all lines, even (especially) the ones with the offending "ss" characters in.

John
ronan.healy
ronan.healy
SSC-Enthusiastic
SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)

Group: General Forum Members
Points: 136 Visits: 232
hi
ya still get error with the single quotes on all line

INSERT INTO [dbo].[SSISLog]
([EventType]
,[PackageName]
,[TaskName]
,[EventCode]
,[EventDescription]
,[PackageDuration]
,[ContainerDuration]
,[InsertCount]
,[UpdateCount]
,[DeleteCount]
,[Host])

VALUES
(
'OnPostExecute',
'"+@[System:TongueackageName]+"',
'"+@[System::TaskName]+"',
0,
'"+@[System::SourceDescription]+"',
'"+ (DT_STR, 6, 1252)DATEDIFF("ss", @[System::StartTime] , GETDATE() ) + "',
'"+ (DT_STR, 6, 1252)DATEDIFF("ss", @[System::ContainerStartTime] , GETDATE() ) + "',
411,
2,
12,
'"+ @[System::MachineName] +"'
)


John Mitchell-245523
John Mitchell-245523
SSCertifiable
SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)

Group: General Forum Members
Points: 7466 Visits: 15142
Mmmm... what happens if you paste that code into SSIS and run it there? I wonder whether it's anything to do with SET QUOTED_IDENTIFIER?

John
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search