April 29, 2015 at 7:42 am
SQL Server 2012 SP2 Enterprise Edition (11.0.5058.0) on Windows Server 2008 R2
At some point a few months ago we encountered an issue where we hit some size limit on the amount of text we could enter into a Transact-SQL step of an Agent job. Attempting to create a job like this with sp_add_job will produce the error
Msg 50000, Level 16, State 10, Procedure sp_add_jobstep_internal, Line 255
String or binary data would be truncated.
Adding the job step via SSMS yields
Alter failed for JobStep 'xxx'. (Microsoft.SqlServer.Smo)
Additional information:
An exception occurred while executing a Transact-SQL statement or batch (Microsoft.SqlServer.ConnectionInfo)
String or binary data would be truncated.
The statement has been terminated. (Microsoft SQL Server, Error: 8152)
I've checked sp_add_jobstep_internal, sp_add_jobstep and the sysjobsteps table and all references to the command field are nvarchar(max). We can run the same job creation code without error on a SQL Server 2008 R2 Enterprise Edition machine and two SQL Server 2012 SP2 Developer Edition boxes. All our 2012 servers were fresh installs, not upgrades.
Any ideas on what is going on and how to fix it would be welcome.
Thanks
Scott
--
Scott
April 29, 2015 at 7:46 am
Scott-144766 (4/29/2015)
SQL Server 2012 SP2 Enterprise Edition (11.0.5058.0) on Windows Server 2008 R2At some point a few months ago we encountered an issue where we hit some size limit on the amount of text we could enter into a Transact-SQL step of an Agent job. Attempting to create a job like this with sp_add_job will produce the error
Msg 50000, Level 16, State 10, Procedure sp_add_jobstep_internal, Line 255
String or binary data would be truncated.
Adding the job step via SSMS yields
Alter failed for JobStep 'xxx'. (Microsoft.SqlServer.Smo)
Additional information:
An exception occurred while executing a Transact-SQL statement or batch (Microsoft.SqlServer.ConnectionInfo)
String or binary data would be truncated.
The statement has been terminated. (Microsoft SQL Server, Error: 8152)
I've checked sp_add_jobstep_internal, sp_add_jobstep and the sysjobsteps table and all references to the command field are nvarchar(max). We can run the same job creation code without error on a SQL Server 2008 R2 Enterprise Edition machine and two SQL Server 2012 SP2 Developer Edition boxes. All our 2012 servers were fresh installs, not upgrades.
Any ideas on what is going on and how to fix it would be welcome.
Thanks
Scott
Why not move that huge amount of sql to a procedure? It would be easier to maintain it there anyway.
_______________________________________________________________
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/
April 29, 2015 at 7:53 am
That's obviously an option but I would like to understand the underlying issue.
--
Scott
April 29, 2015 at 9:28 am
My guess? There's a function call on the command with one of the string functions that's limited to 4000nvarchar/8000varchar. The command field in sysjobsteps is nvarchar(max), but I bet some checking occurs
April 29, 2015 at 9:41 am
Ah. Stand down. Just found out one of our DBAs had put a trigger on msdb.dbo.sysjobsteps for auditing purposes, and was storing the updated step code in a varchar(4000). All resolved now.
--
Scott
April 29, 2015 at 3:14 pm
Thanks for the update.
I hate triggers.
April 30, 2015 at 7:30 am
Steve Jones - SSC Editor (4/29/2015)
Thanks for the update.I hate triggers.
I agree!!! Especially hate them when they don't have the proper datatypes and causes issues like this. They are also really hard to find because they execute invisibly and you just don't think about it much of the time.
Glad you were able to figure out the issue.
_______________________________________________________________
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/
April 30, 2015 at 8:28 am
It would have helped greatly if the error message had referred to the trigger which failed rather than a different stored procedure.
--
Scott
April 30, 2015 at 8:32 am
Scott-144766 (4/30/2015)
It would have helped greatly if the error message had referred to the trigger which failed rather than a different stored procedure.
No kidding. This is yet another reason why they are so darn hard to find. The actual process was the procedure that was executing so the error did in fact occur during that procedure's execution. Triggers will drive you nuts!!!
_______________________________________________________________
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/
April 30, 2015 at 10:22 am
It would be nice if failures in a trigger referred to a tran error in a trigger. But what if a trigger calls a sproc and there's a failure there? The error message is a touch place to implement this on the server since you need to roll through a potential stack of issues.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply