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 ««12

SQLCMD or BCP Expand / Collapse
Author
Message
Posted Friday, November 21, 2008 9:02 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, December 26, 2013 9:45 AM
Points: 3,475, Visits: 577
Was not >> an original UNIX command?


Regards,
Yelena Varshal

Post #606607
Posted Monday, November 24, 2008 1:44 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 3:32 PM
Points: 5,794, Visits: 8,006
It's technically correct that bcp.exe can only replace the contents of a file and output from SQLCMD can be used to append as well, and if the purpose of the question is to remind people of that, then it's a good question.

However, I would not endorse this as a best practice. If I had to append the results of a query to an existing file, I'd either use bcp to output to a temporary file and then concatenate the two together, or I'd start investigating the possibilities of SSIS.

Remember, bcp.exe is written specifically to quickly import or export large amounts of rows, and is optimized for this purpose, while sqlcmd.exe is a general purpose querying tool that is optimized for ad-hoc queries. Also, bcp.exe gives the user lots more control over the formatting of the results.



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #607358
Posted Monday, November 24, 2008 3:16 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, March 20, 2014 7:32 AM
Points: 5,191, Visits: 1,368
Interesting one... To learn more read this
http://msdn.microsoft.com/en-us/library/ms175995.aspx

:)



Post #607385
Posted Monday, November 24, 2008 8:19 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, October 31, 2011 1:10 PM
Points: 480, Visits: 1,163
Btw.. not sure if anyone clicked on the links but the BCP link actually led to an MSDN article about Creating Indexes with Included columns... or is that where it's supposed to go? I thought it would tell me more about BCP rather than index creation. Anyway, thought i'd just add this here...

--
Post #607572
Posted Saturday, November 29, 2008 6:11 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 7:22 AM
Points: 1,052, Visits: 862
Christian Buettner (11/21/2008)
RichardB (11/21/2008)
so why can't you then append the file bcp outputs to the existing file...?

RichardB, you cannot pipe your data out with BCP like with SQLCMD.


No - but whats difficult about outputting it to a new file and appending it to the one you want?
its a whole extra line of code, but hardly a drama.



Post #610815
Posted Monday, December 01, 2008 9:19 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, December 26, 2013 9:45 AM
Points: 3,475, Visits: 577
Richard,

Drama starts after appending!
Now with automatic appending they will have to write another 100 lines of code to prompt for the timely cleanup, checking for the file size, drive space, implementing file roll over etc. Not even talking about the process that will consume the output data, how this process will determine what are the new data. Don't tell me about the log files, they are not normally created by BCP process.



Regards,
Yelena Varshal

Post #611424
Posted Wednesday, January 21, 2009 1:46 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, January 14, 2014 8:44 PM
Points: 1,520, Visits: 739
I think i could not get the question correct, as BCP we can append data into table. but it overrites flat file.:):)

Thanx.
Vinay


http://rdbmsexperts.com/Blogs/
http://vinay-thakur.spaces.live.com/
http://twitter.com/ThakurVinay
Post #641135
Posted Tuesday, February 22, 2011 11:23 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, April 14, 2011 5:36 AM
Points: 30, Visits: 63
Dear Sir , your wrote: " I'd either use bcp to output to a temporary file and then concatenate the two together".

Please tell me that how would this be implemented.
I want that when i insert a record in a table in sql then a trigger is fired on the insert , which executes a stored procedure , the procedure appends the new record into a text file in my C drive.
Post #1068055
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse