Hello,
first of all, i'm sorry for my english and I'll appreciate any suggestion about this thread. I'm trying to export some data from SQL server database using OPENROWSET. Data source contains some fields filled with more than 255 characters. When i try to export these fields to excel I get "String or Binary data would be trucated" error. Here the code:
DECLARE @Folder VARCHAR(MAX) = '\\fileserver\test\'' DECLARE @DocumentLong VARCHAR(MAX) = 'Filename' INSERT temp_table --ad hoc table for this query, created to simplify code SELECT Field1, Field2, Field3 --this one contains more than 255 char; in temp table this field is declared as varchar(1000) FROM database_table WHERE filtered_field = 'value' DECLARE @CMD1 NVARCHAR(4000) SET @CMD1 = 'insert into OPENROWSET(''Microsoft.ACE.OLEDB.12.0'',''Excel 12.0;Database=' + @Folder + @DocumentLong + '.xlsx;'',''SELECT * FROM [Sheet1$]'')SELECT * FROM temp_table' exec sp_executesql @CMD1
You can see that i'm using Excel 12.0 (where cells characters limit is 32,767) so i can't guess which is the problem.
Thank you.