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
 New to SQL Server Programming
 Question about sp_makewebtask

Author  Topic 

HeyZain
Starting Member

7 Posts

Posted - 2011-01-05 : 09:42:37
Hi Folks,

I am using SQL Server 2005 and MS Office 2007 on DB server:

Here is my code:

--------------------------------------------------
set @Qry='Select s.ServiceID, s.MSISDN, s.RequestBy, s.RequestDateTime, s.ServiceStatus, '''' + e.ESMSID + '''' AS [ESMS ID] from Service s, Service_ESMS e Where s.ServiceID = e.ServiceID AND s.RequestDateTime Between '''+convert(varchar,@StartDate,0)+''' AND '''+convert(varchar,@EndDate,0)+''''

set @filepath = 'E:\Scheduled Reports\SmartAgent_DateWise_Report_ESMS.xlsx'

EXEC sp_makewebtask
@outputfile = @filepath,
@query = @Qry,
@colheaders =1,
@FixedFont=0,@lastupdated=0,@resultstitle='Auto Generated Date Wise ESMS Report'

--------------------------------------------------

The problem is that, column ESMSID in Service_ESMS table is of type VARCHAR(500) and contains comma separated 3 digit numeric values. When the file is exported to Excel using above code, Excel treats the column as numeric and does not show the values surrounded by single quotes.

When i execute the above SQL query in New Query window, and copy the results from result pan to excel sheet, the column values are shown surrounded by single quotes (as required).

Please suggest how i can make sp_makewebtask to export data to excel sheet with ESMSID column
surrounded by single quotes so that it is treated as string.

Thanking in advance.

Regards,

Z@in

HeyZain
Starting Member

7 Posts

Posted - 2011-01-05 : 10:59:38
Guys......... Waiting for response

Z@in
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-01-05 : 11:10:24
I have alerted the SQL authorities that you have been waiting over an hour for your response. Heads are going to roll!

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -