Solved

BCP export to Text file skips rows

Posted on 2009-07-06
2
331 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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

813 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now