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
 General SQL Server Forums
 Script Library
 Export Numbers from SQL Server to Excel

Author  Topic 

twl55
Starting Member

19 Posts

Posted - 2011-08-30 : 10:31:13
I am successfully exporting the results of a SQL Server 2005 query to Excel in a stored procedure using OPENROWSET.

My number and date fields all arrive in the spreadsheet as character strings (left-justified, don't sort as numbers, etc).

I had hoped just by formatting the cells as numbers in the destination spreadsheet they would arrive as numbers, but they are still strings.

Is there someway to get them to be numbers in the destination spreadsheet?

Thanks

twl55

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-30 : 10:47:06
whats the datatype of fields in SQL Server?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

twl55
Starting Member

19 Posts

Posted - 2011-08-30 : 10:56:27
decimal(19,9)

and

datetime using CONVERT(dt, 101)

twl55
Go to Top of Page

twl55
Starting Member

19 Posts

Posted - 2011-08-30 : 12:43:51
Actually,

decimal(19,9)
int
datetime as CONVERT(dt,101)

twl55
Go to Top of Page

twl55
Starting Member

19 Posts

Posted - 2011-09-01 : 17:11:28
Does anyone know of any other alternatives to OPENROWSET to have SQL Server place query results into an Excel spreadsheet if I cannot figure out how to get numeric fields in SQL Server to be numeric in Excel output? I saw a number of web references to this problem but none seemed to be connected to SQL Server.

Thanks

twl55
Go to Top of Page
   

- Advertisement -