Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

BCP export to Text file skips rows

Posted on 2009-07-06
2
Medium Priority
?
338 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:Tom Sage
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
Philip Pinnell earned 1500 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:Tom Sage
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

719 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