Solved

Exporting database to CSV files

Posted on 2010-09-21
6
733 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
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 51

Expert Comment

by:HainKurt
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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 23

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 23

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 23

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Read about achieving the basic levels of HRIS security in the workplace.
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now