parameter size in execute sql task is not working
Hello, I am executing a stroc proc using execute sql task . I am passing 2 parameters as follows Connection: OLE DB SQLStatement : exec sp_UpdateReportLog ?,6 Bypassprepare : True The parameter mapping is as follows: VariableName Direction DataType ParamName ParamSize User::SourceFile Input NVARCHAR 0 -1 When I execute the task i recieved the following error. Error: String or binary data would be truncated. [Execute SQL Task] Error: Executing the query "EXEC [dbo].sp_UpdateReportLog ?, ?, 6 " failed with the following error: "The statement has been terminated.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. The variable User::SourceFile size has a value of 110 char lenght, combined path + filename. I did a regression testing by truncating the file name by 1 until it executed sucessfully at 100. It would seems that the default parameter size of -1 can only handle up to 100 char size. So I went ahead and change it to 256 thinking it would solved the problem but it didn't. Note: AS a work around, I would have to reduce the file name size but this is not an option. The file name contains rules that is important in our processing and is received by us from a third party. I am using SQL 2005 SP3. Any advise would be greatly appreciated. Thanks, SQLBIBabe
September 28th, 2011 5:11pm

Error: String or binary data would be truncated. [Execute SQL Task] Error: Executing the query "EXEC [dbo].sp_UpdateReportLog ?, ?, 6 " failed with the following error: Though you are saying that you are passing 2 parameters but the error message says that there are 3 (?,?,6). You have not mapped the 2nd parameter. Also would like to know about the result set and what is your setup for that.
Free Windows Admin Tool Kit Click here and download it now
September 28th, 2011 5:26pm

You are right, it should only say 2 param - typo error. The correct SQLStatement should read as follow: EXEC [dbo].sp_UpdateReportLog ?, 6 Where ? is mapped to a package variable SourceFile as stated earlier.. There is no result set setup needed. The stored procedure does not return anything, it simply performs table update. As mentioned, the error only appears when the value of the SourceFile variable exceeds 100 character in length. Increasing the parameter size on the mapping does not work either. What am I missing here ? Here is how you may duplicate the error First create any file, place it a temp folder (or any folder you want), make sure the combined path and file name (including the file extension) exceeds 100. The in BIDS, Create a new package, Create a package level string variable, call it SourceFile The drop a Foreach loop file enumerator, map the variable, setup the folder and the file name to the one you created (make sure to choose fully qualified file) then drop Execute SQL task inside the foreach loop, map the variable SourceFile and type in the sqlstatement as stated above You may have to create the stored proc with the input parameter to match, you may just update any table Run the package to see if you got the same error. Try increasing the parameter size as well .. Goodluck, looking forward to know what I might be possibly doing wrong. aem
September 29th, 2011 4:18am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics