Solved

SQL datbase export

Posted on 2013-07-01
3
347 Views
Last Modified: 2016-02-11
I am trying to export a SQL database which I generally do in SQL Server Management Studio (2008) using Generate Scripts. This works fine for exporting the entire database and data, however, I'd like to just export only select fields. I tried creating a view and exporting only the view but I never saw any of the data (even after selecting  "Schema and Data" in types of data to script under Advanced.
Is there a way to export data and schema using a Select query for only certain fields and data you'd like exported?
Thanks!
0
Comment
Question by:cbeverly
[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
  • 2
3 Comments
 
LVL 23

Expert Comment

by:nemws1
ID: 39291257
Well... there's always a way.  Whether or not its a *nice* way is debatable.  There's no direct way of doing what you want.

My suggestion - create a new table containing the data structure you want and export that (then delete it):

SELECT f1
  , f2
  , f3
INTO new_table_to_export
FROM original_table
WHERE condition if you need it

// export your table ....

DROP TABLE new_table_to export

Open in new window

0
 
LVL 30

Accepted Solution

by:
Rich Weissler earned 500 total points
ID: 39291288
If you already created a view, and wanted to export the data from a view, could you not use the SQL Server Import and Export Wizard, and in the 'Select Source Tables and Views' -> select the view you wanted to export that data through?

It all just uses SSIS, so ultimately you could do even more customization by firing up your Visual Studio with BITS.
0
 
LVL 23

Expert Comment

by:nemws1
ID: 39291324
Another option would be to use 'bcp' with a query.  That'll export a table out as well, and you can specify how you want it formatted:

http://msdn.microsoft.com/en-us/library/ms191485.aspx

Not sure what you're then trying to import this into.  If its another SQL server, you can use BCP's internal binary format.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

631 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