no columns | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

no columns

I will be using bcp tool within dts but unfortunately, I don’t know what I am missing. I don’t see the column names when I use bcp to export the result of a simple select query. Please help. Thanks, V1rt
hey guys, I just used the dts wizard and it went well. I used the destination text file. However, I don’t know how I can make the filename dynamic. I want to create a dts package wherein it creates a daily file every morning but destination file will be based on current day/date. Example, log20050128.txt Can someone please help? Thanks….
http://www.sqldts.com/default.aspx?292
Check the above, Sorry for the delayed answer
quote:Originally posted by v1rtu0s1ty hey guys, I just used the dts wizard and it went well. I used the destination text file. However, I don’t know how I can make the filename dynamic. I want to create a dts package wherein it creates a daily file every morning but destination file will be based on current day/date. Example, log20050128.txt Can someone please help? Thanks….

You can use a workaround to get the column headers out
use pubs
if object_id(‘workaround’)>0
drop view Workaround
go
create view Workaround as
select
au_id
, au_lname
, au_fname
, convert(char, contract) ‘contract’
, 1 as SeqNo from authors
union
select
‘au_id’
, ‘au_lname’
, ‘au_fname’
, ‘contract’
, 0 as SeqNo
go
declare @stmt varchar(200)
set @stmt = ‘bcp "select au_id, au_lname, au_fname, contract from pubs..Workaround order by SeqNo, au_id" ‘
set @stmt = @stmt + ‘queryout "C: ext.txt" -c -T -S’
exec master..xp_cmdshell @stmt However, I think this would be only a solution if your query output remains static, since you need to included the literals. And they don’t care about a column being included or not. —
Frank Kalis
SQL Server MVP
http://www.insidesql.de

]]>