NNTP-Posting-Date: Fri, 22 Jun 2012 12:48:37 -0500 From: "Cathy" Newsgroups: comp.databases.ms-sqlserver References: <5oudnZwNaMRT-37SnZ2dnUVZ8g-dnZ2d@bt.com> In-Reply-To: Subject: Re: MSSMSE - Export results to CSV Date: Fri, 22 Jun 2012 18:48:29 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6002.18197 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18463 Message-ID: <1JudnbRjP9BoMnnSnZ2dnUVZ8lmdnZ2d@bt.com> Lines: 43 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-9Lrd/e2JycZyKx+Cq/zTlIPUN0VRpSyHqNVFsPm4ajQEonc7+o/pZ2bcuMtBlNPVa10caF/ADqtcq9E!rCoNC6kJ1+OpgC4YqxGX8U8gfBMEpbe81DK7jKveYdHMN6We4XKPuNTyH+Y63o94NknojBoBqoI= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3015 Path: csiph.com!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail Xref: csiph.com comp.databases.ms-sqlserver:1151 > So what was wrong with the format? Well as you said ">Beware that if there is comma in the data, bcp will not quote the value." Try to open the file exported via MSSMSE and the once created by BCP after doing this and you will note the difference This is the bcp command I am using., try the same with bcp "SELECT CategoryID, CategoryName, Description FROM [Northwind].[dbo].[Categories]" queryout outputfile.csv -c -t, -CRAW -T -S PCNAME\SQLEXPRESS Results when opened up in Excel is very different and not acceptable. I could use the wizard, but the idea is to get a script that I can run against many databases, to export the results individually whilst running. Saving file data manually is almost easier and quicker than using the wizard, unless I am missing a trick. ***RESULT of BCP*** 1,Beverages,Soft drinks, coffees, teas, beers, and ales 2,Condiments,Sweet and savory sauces, relishes, spreads, and seasonings 3,Confections,Desserts, candies, and sweet breads 4,Dairy Products,Cheeses 5,Grains/Cereals,Breads, crackers, pasta, and cereal 6,Meat/Poultry,Prepared meats 7,Produce,Dried fruit and bean curd 8,Seafood,Seaweed and fish *** RESULT OF MSSMSE*** CategoryID,CategoryName,Description 1,Beverages,"Soft drinks, coffees, teas, beers, and ales" 2,Condiments,"Sweet and savory sauces, relishes, spreads, and seasonings" 3,Confections,"Desserts, candies, and sweet breads" 4,Dairy Products,Cheeses 5,Grains/Cereals,"Breads, crackers, pasta, and cereal" 6,Meat/Poultry,Prepared meats 7,Produce,Dried fruit and bean curd 8,Seafood,Seaweed and fish