Tom Sage
asked on
BCP export to Text file skips rows
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
Thanks for any ideas
ALTER Procedure [dbo].[BCP_to_Text]
(
@table varchar(255),
@FileName varchar(255)
)
as
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+'" -T -c'''
Exec(@str)
end
else
Select 'The table '+@table+' does not exist in the database'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER