user1943247
user1943247

Reputation: 3

Execute SQL Task fails in SSIS 2008 package but runs successfully outside package

I created an execute sql task to save the filenames encountered in a Foreach Loop task into a database table, this works fine when I run the the individual task and it writes the filename to the database table (see below) UNABLE TO POST IMAGES CURRENTLY ![task successfully runs][1] However when i run the complete SSIS package, this task fails (see below) UNABLE TO POST IMAGES CURRENTLY

![unsuccessful execution][2] The error message I am getting is:

Error: String or binary data would be truncated.
[Execute SQL Task] Error: Executing the query "insert into filename_staging_table
(FileName) Val..." 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.

Any guidance with this greatly appreciated....I am completely stuck!!!!

Thanks

Upvotes: 0

Views: 7708

Answers (1)

twoleggedhorse
twoleggedhorse

Reputation: 5048

The error reads "String or binary data would be truncated." The reason the script works when run manualy is because you are only trying to insert one value. That value is within the length constraint of your column.

When you run the task, it is looping through a list of filenames and trying to insert each one. One of these names is too long for the field you are trying to insert it into.

You need to change the length of the field in SQL or you need to use a LEFT(filename, xx) on the filename itself so that a only the first xx characters are inserted into your table. (Change the xx to the number of characters to be inserted)

Upvotes: 1

Related Questions