Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Query Error

Author  Topic 

praveen_1267
Starting Member

1 Post

Posted - 2011-07-07 : 14:31:02
Hi all,

i have to execute insert query which contains 500+ columns and while executing that query i am getting "string or binary data would be truncated".
How can i know at which column the error is?

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-07-07 : 16:24:03
If it isn't already, put the data to be inserted into a staging table.

In your query editor, set the output to text. Change YOUR_STAGING_TABLE and YOUR_TARGET_TABLE to the name of your table(s). Copy/Paste the results of this into a new window and execute it:
SELECT	'SELECT MAX(LEN([' + name + '])) [length], ' +
Convert(varchar(255), CASE WHEN system_type_id in (231, 239) THEN max_length / 2 ELSE max_length End) + ' [max allowed]
FROM YOUR_STAGING_TABLE;'
FROM sys.columns
WHERE object_id = object_id('YOUR_TARGET_TABLE')
And system_type_id in (175, 239, 231, 167)
Go to Top of Page
   

- Advertisement -