Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««910111213

Exporting to Excel Using a CLR Stored Procedure Expand / Collapse
Author
Message
Posted Wednesday, March 28, 2012 6:21 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, April 15, 2013 6:45 AM
Points: 2, Visits: 33
I finally got it last night. What you have to do is a few converts on the datetime field. Here is a quick example...

--Exporting to Excel
DECLARE @cdate NVARCHAR(MAX)
SET @cdate = '2012-03-24T00:00:00' -- XML DATTIME
SET @params = '<params><param name="cdate" value="' + @cdate + '" /></params>'
exec prc_ExportToExcel 'Your Stor Proc', 'Your File Loc', 'Name', @params

--Stor Proc Examp
DECLARE @cdate DATETIME
SELECT Date
FROM Table
WHERE (Table.Date <= CONVERT(DATETIME, @cdate, 126)) --126 lets SQL know that it is a XML DATETIME format, and converts it to SQL DATETIME format

Hope this helps someone who may need to do the same thing I was working on :)
Post #1274232
Posted Tuesday, December 11, 2012 9:13 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Saturday, November 15, 2014 2:46 AM
Points: 552, Visits: 70
Thanks!!!
This saved a great deal of my time!
Post #1395413
Posted Friday, July 12, 2013 4:12 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, November 28, 2013 3:23 AM
Points: 48, Visits: 95
we can do the excel formatting, like bold the column or colours the column
Post #1472929
« Prev Topic | Next Topic »

Add to briefcase «««910111213

Permissions Expand / Collapse