Please look at the BCP statement below. It does export data to a text file, but it skips some of the rows. I know BCP is skipping rows because I compared the BCP output with the output from a .NET program using a DataReader where I exported one row at a time. I would like to use BCP because it is faster.
Thanks for any ideas
ALTER Procedure [dbo].[BCP_to_Text]
If exists(Select * from information_Schema.tables where table_name=@table)
Declare @str varchar(1000)
set @str='Exec Master..xp_Cmdshell ''bcp "Select * from '+db_name()+'..'+@table+'" queryout "'+@FileName+'" -T -c'''
Select 'The table '+@table+' does not exist in the database'