We help IT Professionals succeed at work.
Get Started
Troubleshooting Question

Export from SQL to EXCEL with long string

45 Views
Last Modified: 2021-01-08
hi,

This is the code I use to export SQL output to Excel

EXEC SP_CONFIGURE 'show advanced options', 1; 
GO 
RECONFIGURE; 
EXEC SP_CONFIGURE 'Ad Hoc Distributed Queries', 1; 
GO 
RECONFIGURE; 




INSERT INTO OPENROWSET ('Microsoft.ACE.OLEDB.12.0', 
'Excel 12.0;HDR=YES;Database=\\192.168.78.88\c$\Users\my.LOCAL\Desktop\Excel\my.xlsx;', 
'SELECT * FROM [test$]') 


Select F1, F2, F3....
From Table1
Where a=1


I need to have an Excel with same number of columns as in Select statement. One of the fields is comment, it is long, so I receive this error

Msg 8152, Level 16, State 10, Line 14
String or binary data would be truncated.
The statement has been terminated.

thanks

Comment
Watch Question
Sr. System Analyst
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 60 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE