Solved

Exporting database to CSV files

Posted on 2010-09-21
6
736 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a starter for ETL protocol? 4 65
constraint check 2 48
Querying data from 3 SQL tables 2 36
Access 2016 Query with Proper Case logic 2 28
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Creating and Managing Databases with phpMyAdmin in cPanel.
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…

808 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