![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have tried saving the script and running it with osql (sorry should have mentioned earlier this is still an old SQL2000 server) But unfortunately the resultant CSV file seems to have a lot of blank spaces and wraps lines and just is not in the same CSV format as that exported in first step. I am therefore wondering if there is not a way in which I could add something into the SELECT statement to save reults to CSV file and hope the results come out in the same format, |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
I was just looking at BCP, struggled a bit, got most of it working in the end, but still not quite the same format. |
|
I was in fact hoping there was a way I could specify outfile as can be done in MySQL but I dont seem to get this option in MSSMSE |
#5
| |||
| |||
|
|
So what was wrong with the format? |
#6
| |||
| |||
|
|
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 |
#7
| |||
| |||
|
|
SELECT CategoryID, CategoryName, quotename(Description, '"') FROM [Northwind].[dbo].[Categories] |
#8
| |||
| |||
|
|
This is brilliant SELECT CategoryID, CategoryName, quotename(Description, '"') FROM [Northwind].[dbo].[Categories] Only problem I have now is that bcp reads the quote as the end of the command. Is there a way to escape this? bcp "SELECT CategoryID, CategoryName, quotename(Description, '"')FROM [Northwind].[dbo].[Categories]" queryout outputfile.csv |
#9
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |