Solved

BCP export to Text file skips rows

Posted on 2009-07-06
2
332 Views
Last Modified: 2012-05-07
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]
(  
@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'

Open in new window

0
Comment
Question by:MisterT25
2 Comments
 
LVL 13

Accepted Solution

by:
Philip Pinnell earned 500 total points
ID: 24792208
If you run bcp Select * from table queryout fileName -T -c
 manually from the command prompt do you get the same results and does it have as many records as running Select * from table in query analyser ?


0
 

Author Closing Comment

by:MisterT25
ID: 31600419
Thank you for your feedback.  I have decided not to use bcp since I do not have enough time to resolve this problem.  Closing this case.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question