ie,
create view myView
as
select t.c1,t.c2,t.c3
from
(select 1 i, 'col1name' c1, col2name' c2, 'col3name' c3...
union
select 2 i,cast(col1 as varchar) c1, cast(col2 as varchar) c2, cast(col3 as varchar) c3... from yourtable) t
order by t.i asc
then your bcp code:
Declare @sql varchar(8000)
select @sql = 'bcp "select * from myView" queryout C:\ -c -t, -T -S' + @@servername
exec master..xp_cmdshell @sql
Main Topics
Browse All Topics





by: frankyteePosted on 2008-06-19 at 18:33:06ID: 21827825
create a view which contains the field names (using union) and bcp the view, check out e.com/Micr osoft/Deve lopment/MS -SQL- Serve r/Q_226590 46.html
http://www.experts-exchang