>I am able to export to excel through a stored procedure.But when i
>open it the datetime column and int columns are not getting recognised.
>
This is the code i wrote:
I have difficulties to understand where you procedure ends, and which
are the test stuff you do. What I can see, you build a BCP command with
queryout:
There you export the full table. Furthermore, you use native format
(-n), and Excel is not likely to understand that.
Also, I don't think you should export to an .xls file. I don't know
Excel that well, I would think that Excel expects a binary file when
you have .xls. Shouldn't you use .csv instead?
I've also seen people export to Excel using OPENROWSET or OPENQUERY,
but I have not done this myself.
On Mar 28, 3:57 am, Erland Sommarskog <esq...@sommars kog.sewrote:
(nalamve...@gma il.com) writes:
On Mar 27, 5:08 pm, nalamve...@gmai l.com wrote:
I am able to export to excel through a stored procedure.But when i
open it the datetime column and int columns are not getting recognised.
>
This is the code i wrote:
>
I have difficulties to understand where you procedure ends, and which
are the test stuff you do. What I can see, you build a BCP command with
queryout:
>
>
There you export the full table. Furthermore, you use native format
(-n), and Excel is not likely to understand that.
>
Also, I don't think you should export to an .xls file. I don't know
Excel that well, I would think that Excel expects a binary file when
you have .xls. Shouldn't you use .csv instead?
>
I've also seen people export to Excel using OPENROWSET or OPENQUERY,
but I have not done this myself.
>
--
Erland Sommarskog, SQL Server MVP, esq...@sommarsk og.se
>
Books Online for SQL Server 2005 athttp://www.microsoft.c om/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.c om/sql/prodinfo/previousversion s/books.mspx
I have tried using openrowset aswell openquery.But i am getting an
error in
server name. My servername has '-' symbol.
I took the code from the following link:
Four T-SQL techniques for moving data between SQL Server and Excel: linked servers, OPENROWSET, sp_makewebtask, and OLE Automation for formatted reports.
I am a beginner in this field. I dont know how to convert from csv to
xls.
Please guide me thorugh this.
Comment