Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1151

Re: MSSMSE - Export results to CSV

NNTP-Posting-Date Fri, 22 Jun 2012 12:48:37 -0500
From "Cathy" <Cathy@Nospam.com>
Newsgroups comp.databases.ms-sqlserver
References <5oudnZwNaMRT-37SnZ2dnUVZ8g-dnZ2d@bt.com> <XnsA079F0DCCBB92Yazorman@127.0.0.1> <FpednYO2bofgOn7SnZ2dnUVZ8kydnZ2d@bt.com> <XnsA07A7596B3550Yazorman@127.0.0.1>
In-Reply-To <XnsA07A7596B3550Yazorman@127.0.0.1>
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> (permalink)
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

Show key headers only | View raw


> 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

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

MSSMSE - Export results to CSV "Cathy" <Cathy@Nospam.com> - 2012-06-21 19:24 +0100
  Re: MSSMSE - Export results to CSV Erland Sommarskog <esquel@sommarskog.se> - 2012-06-21 23:40 +0200
    Re: MSSMSE - Export results to CSV "Cathy" <Cathy@Nospam.com> - 2012-06-22 00:00 +0100
      Re: MSSMSE - Export results to CSV Erland Sommarskog <esquel@sommarskog.se> - 2012-06-22 11:33 +0200
        Re: MSSMSE - Export results to CSV "Cathy" <Cathy@Nospam.com> - 2012-06-22 18:48 +0100
          Re: MSSMSE - Export results to CSV Erland Sommarskog <esquel@sommarskog.se> - 2012-06-22 20:38 +0200
            Re: MSSMSE - Export results to CSV "Cathy" <Cathy@Nospam.com> - 2012-06-22 22:45 +0100
              Re: MSSMSE - Export results to CSV Erland Sommarskog <esquel@sommarskog.se> - 2012-06-23 11:28 +0200
                Re: MSSMSE - Export results to CSV "Cathy" <Cathy@Nospam.com> - 2012-06-23 23:49 +0100

csiph-web