Solved

SQL datbase export

Posted on 2013-07-01
3
334 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
  • 2
3 Comments
 
LVL 23

Expert Comment

by:nemws1
Comment Utility
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 29

Accepted Solution

by:
Rich Weissler earned 500 total points
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Lessons learned during ten years of interviewing for SQL Server Integration Services (SSIS) and other Extract-Transform-Load (ETL) contract roles and two years of staff manager interviewing contractors.
My client has a dictionary table. They're defining a list of standard naming convention. Now, they are requiring my team to provide us a mechanism how to match new incoming data with existing data in their system.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.

762 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

12 Experts available now in Live!

Get 1:1 Help Now