Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
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
Posted Wednesday, January 16, 2013 9:23 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, October 12, 2015 7:07 AM
Points: 48, Visits: 174

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,
Post #1407924
Posted Wednesday, January 16, 2013 10:13 AM



Group: General Forum Members
Last Login: Today @ 3:21 PM
Points: 13,884, Visits: 35,803
I'd look at with checking the data existence first:
if NOT EXISTS(SELECT 1 FROM SomeTable WHERE SomeCriteria = X)
--BCP code goes here


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