SQL Server 2008 Export data as a script [SQL Server]

Source: Internet
Author: User
Tags table definition management studio sql server management sql server management studio

Before we had to export the data from a table to a script, the data script could be exported only if we looked for an exported scripts on the web and then ran them. A new feature has now been added to Management Studio in SQL Server 2008, which supports exporting data from tables to scripts in addition to the definition of the exported table. Export process:

In Object Explorer in SSMS2008 (SQL Server Management Studio 2008), right-click the database for which you want to export data, and in the pop-up menu choose the Generate Script option under tasks.
In the Script Wizard's Select scripts option, you have the following important options to choose from:

    • Script for writing data: whether to export table data from the database.
    • "Contains If not Exists": This option removes database objects that already exist in the database with the same name.
    • Write script to create database: whether to produce SQL script
    • Scripting Server version: Select the version of the database to execute the script.

Then the next step is to select the exported object, select the exported table, and when finished, you will see the table definition and table data exported by the system.

If the script is to be used by the remote database. Generally to change two places, the first place is create DATABASE [DBNAME] (if you have selected the "script to create databases" option) and use [database]. The second place is to change the database schema, the general Local is the DBO, so press the Ctrl+f key, select the replacement window, the DBO is replaced by [Your_schema] This script to complete the transformation. Next, you can open the remote database, create a new query, copy the script just now, execute!

However, in the actual operation, if you export from 08 to a lower version of SQL may have a lot of compatibility problems, so when you export the script to a low-level version

In Select Database , you can uncheck the script all objects in the selected database check box

In Select script Options , Note Select the exported database version (2000,2005,2008) in script for server version

(GO) SQL Server 2008 Export data as a script [SQL Server]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.