Solved

Exporting database to CSV files

Posted on 2010-09-21
6
738 Views
Last Modified: 2012-08-14
Pardon me for posting this in slightly the wrong place. I don't see any option for SQL in general or SQL 2000.

I need to export a SQL2000 data to CSV files. One for each table. Everything I am seeing says to use DTS. Following the examples I have found, I seem to be missing a step. The screen shots show a step where you can choose what tables are exported. I'm not getting that option. I get a drop down of all the tables, so I can only pick one.

If there is a way to make this work, or someone can point out another way to export all the table to individual CSVs, that would be great.

Thanks!
0
Comment
Question by:Brian B
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Accepted Solution

by:
jijeesh earned 400 total points
ID: 33729524
Use bcp you can do it..

declare @sql varchar(8000)
select @sql = 'bcp master..sysobjects out
                c:\bcp\sysobjects.txt -c -t, -T -S'+ @@servername
exec master..xp_cmdshell @sql


http://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/
0
 
LVL 53

Expert Comment

by:Huseyin KAHRAMAN
ID: 33729527
what is "examples" or tools are you using? where is the screenshot?
0
 
LVL 12

Assisted Solution

by:jagssidurala
jagssidurala earned 100 total points
ID: 33731848
its is a simple application to get the csv file by entering the table name.

http://www.codeproject.com/KB/aspnet/ImportExportCSV.aspx

This link will give you an idea to get csv file by a sql query.
 
http://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/
0
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
LVL 24

Author Comment

by:Brian B
ID: 33748305
The link on the simple-talk website is almost exactly what I need. In fact I ran it and got all my data exported. Then I realized that BCP doesn't export the columns names. I have looked up how to include them, but again the samples are only written for one table, not the entire database.

Here's the code I am using to generate another page of code that I run to produce the export. How would I modify this to include column names?

select 'exec master..xp_cmdshell'
             + ' '''
             + 'bcp'
             + ' ' + TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME
             + ' out'
             + ' e:\export\'
             + TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME + '.bcp'
             + ' -t, -T -S' + @@servername
             + ''''
from INFORMATION_SCHEMA.TABLES
where TABLE_TYPE = 'BASE TABLE'
0
 
LVL 24

Author Comment

by:Brian B
ID: 33753871
I finally hit on the right combination of search words and found a great little utility called SQLtoTXT (http://www.withdata.com/sqltotxt.html) that did the trick. The trial version will only export the first 1000 records from each table, but I just did manual export for those.

Thanks everyone for your help and time.
0
 
LVL 24

Author Closing Comment

by:Brian B
ID: 33769627
Although this wasn't the final solution I used, the informationw as still helpful. Thanks!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question