Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to stop exporting an empty file using bcp utility Expand / Collapse
Author
Message
Posted Wednesday, January 16, 2013 9:23 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, February 3, 2016 9:40 AM
Points: 50, Visits: 178
Hi,

I am using bcp utilti using xp_cmdshell to export table data into txt file.
but I do not want to export the data for an empty file as it will create an empty txt file on the destination.
How do I do that?

Any suggestions?

Thanks in advance,
Blyzzard
Post #1407924
Posted Wednesday, January 16, 2013 10:13 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:42 PM
Points: 14,445, Visits: 37,858
I'd look at with checking the data existence first:
if NOT EXISTS(SELECT 1 FROM SomeTable WHERE SomeCriteria = X)
BEGIN
--BCP code goes here
END


Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Post #1407983
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse