February 8, 2006 at 6:02 am
Hi,
Iam able to send the output query to an excel file by using the below:
master..xp_cmdshell 'bcp "select empno,ename,deptno from emp",queryout d:\filename.xls -c -s servername -u userid -p password -e.
the above command is working fine but problem is formatting of excel file.
I need to format like first row has to bold,all the columns has to autofit automatically.
Is this possible through sql query?
I thought different solutions like :
sol1:
Take a template of excel file and insert the data into existing excel file.
can i know how to insert the data into existing excel template file?
sol2:
calling a .Net exe from sql server stored procedure for formatting.
If u have any solutions please let me know
February 8, 2006 at 8:26 am
Have you tried embedding the SQL Query in the Excel spreadsheet?
Data -> Import External Data -> New Database Query.
You can use Query Manager to build the query if it is simple. For complex ones, I develop them externally in Query Manager and then Copy/Paste them in.
The returned results are formatted in the manner you describe.
You can update the spreadsheet using the Refresh Data button on the External Data toolbar.
February 8, 2006 at 8:35 am
use the DTS wizard for impot/export the records??
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply