0

I have requirement that, Need to export the sql output data to excel sheet. To acheive this i am executing the below query,

xp_cmdshell'sqlcmd -s  -U aaaa -P bbbbb -d dbao -Q " set nocount on;select * from table_tmp" -s "," -o D:\temp_table.xls

The query is executing fine but the issue which i am facing while executing that query is,

I am loosing the extract format of the columns

E.g., 0000012345 is stored as 12345 ( since it is numeric value xls by default removing preceeding zero's.

Is there a way to load the data in excel with format as text.

Thanks.

Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
baski
  • 1
  • 2

0 Answers0