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


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

Re: MSSMSE - Export results to CSV

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>
Subject Re: MSSMSE - Export results to CSV
Date 2012-06-22 18:48 +0100
Message-ID <1JudnbRjP9BoMnnSnZ2dnUVZ8lmdnZ2d@bt.com> (permalink)

Show all headers | 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