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
 bcp comma delimited file format

Author  Topic 

crbnldy
Starting Member

1 Post

Posted - 2006-01-10 : 09:21:53
i'd like my output text file fromthe following to be in this format
"field 1","field2","field3","field4"

but instead it is showing this way
field 1","field2","field3","field4 it is missing the opening and closing "


here is the stored procedure i am running

declare @today datetime
Declare @table varchar(100)
declare @FileName varchar(100)
set @today = getDate()
set @table = 'tblOptOut'
set @FileName = 'C:\Upload\upload_ccsi.txt'

If exists(Select * from information_Schema.tables where table_name=@table)

Begin
Declare @str varchar(1000)
set @str='Exec Master..xp_Cmdshell ''bcp "Select * from '+db_name()+'..'+@table+'" queryout "'+@FileName+'_'+convert(char(10),@today,120)+'" -t """,""""'+'" -c"'''
Exec(@str)
end
else
Select 'The table '+@table+' does not exist in the database'
GO

what am i doing wrong?
   

- Advertisement -