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
Author
Message
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: Yesterday @ 2:33 PM
Points: 40, Visits: 137
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: Yesterday @ 9:31 AM
Points: 12,962, Visits: 32,501
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1407983
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse