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
 xp_cmdshell issue

Author  Topic 

ramemail.n
Starting Member

8 Posts

Posted - 2010-07-28 : 12:28:45
declare @dateformat varchar(100)
select @dateformat = convert(varchar(15), getdate(),102)
select @dateformat
declare @sql varchar(100)
set @sql = 'bcp "SELECT top 10 * FROM report..carriers" queryout "D:\bcptest' + @dateformat + '.txt" -T -c -t,'
select @sql
exec xp_cmdshell @sql

using above script i am able to copy the data from table to text file
but i am not getting header how to get the header in each file.

Thanks,
Rammohan

Rammohan N

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-07-28 : 13:11:06
Duplicate, locking topic.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -