Table Name = ColorTable
| ID | ColorSerial | ColorPart | ColorType |
| ID | ColorSerial | ColorPart | ColorType |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 8, 2012, 1:41 AM EST
http://www.c-sharpcorner.com/Forums/Thread/161804/covert-sql-data-into-csv-file.aspx
David SmithRank #999 · 2K reputationPosted Mar 9, 2012, 5:13 AM EST
Ok this works below from the command line, when I execute this in management studio, it is executing properly, but never writes the file to disk. But if execute the same bcp from the command line it works just find. Can some tell me why is not writing the file to local disk. And also how to include the headers from the table in the bcp, It only returns the rows and columns without the header fields.
BEGIN
DECLARE @sql varchar(8000)
SET @sql = 'bcp "SELECT * FROM ColorDatabase.dbo.ColorTable" queryout "C:\Temp\Example.txt" -c -t; -T -SXXXXXXXXXX'
Print @sql
exec master..xp_cmdshell @sql
END
VulpesRank #55 · 29.2K reputationPosted Mar 9, 2012, 6:00 AM EST
http://stackoverflow.com/questions/1355876/export-table-to-file-with-column-headers-column-names-using-the-bcp-utility-an
David SmithRank #999 · 2K reputationPosted Mar 9, 2012, 2:55 PM EST
David SmithRank #999 · 2K reputationPosted Mar 9, 2012, 6:09 PM EST
this works below, but once I execute the bat file I have no way of knowing when its down, what I am doing is copying all data to text files, then afterwards, delete from the database. So is there a way to know if the bat file has finished exectuting berfore deleting from the database.
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = Directory.GetCurrentDirectory.;
if (File.Exists(RapidViewClient.Properties.Settings.Default.ExamplePath))
{
process.StartInfo.CreateNoWindow = false;
process.Start();
}
VulpesRank #55 · 29.2K reputationPosted Mar 11, 2012, 5:19 AM EDT