SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Export Numbers from SQL Server to Excel
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

twl55
Starting Member

USA
19 Posts

Posted - 08/30/2011 :  10:31:13  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 08/30/2011 :  10:47:06  Show Profile  Reply with Quote
whats the datatype of fields in SQL Server?

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

Go to Top of Page

twl55
Starting Member

USA
19 Posts

Posted - 08/30/2011 :  10:56:27  Show Profile  Reply with Quote
decimal(19,9)

and

datetime using CONVERT(dt, 101)

twl55
Go to Top of Page

twl55
Starting Member

USA
19 Posts

Posted - 08/30/2011 :  12:43:51  Show Profile  Reply with Quote
Actually,

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

twl55
Go to Top of Page

twl55
Starting Member

USA
19 Posts

Posted - 09/01/2011 :  17:11:28  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000