SQL Server 2008 Export/restore/Compatibility to SQL Server 2005, 2000 samples

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

Before we had to export the data from one table to a script, we would be able to export the data script by looking for a script to export the data on the web and then run it. A new feature is now added to Management Studio in SQL Server 2008, which supports exporting data from a table as a script, in addition to the definition of a 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, select the Generate Script option under tasks.
In the Script Wizard's Select script option, you have the following important options:

Script to write data: whether to export table data from the database.

"Contains If not Exists": This option deletes database objects that already exist in the database with the same name.

"Write script to create a database": whether to generate SQL scripts for creating databases


2010102022563956
"Scripting for Server Versions": Select the version of the database to execute the script.

Next, select the exported object, select the exported table, and when you are finished, you can see the table definition and table data exported by the system.

1) In addition there are two places to pay attention to.

A, create DATABASE [dbname] (if you have selected the script to create databases option) and use [db].

Second, to change the database structure, the general local is using dbo, so press ctrl+f key, select the replacement window, the dbo replaced by [Your_schema] to complete the script transformation.

2) But in practice, if you export from 08 to a lower version of SQL, there may be many compatibility issues, so when you export scripts to a low-level version

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

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

3 How large the exported script cannot be directly opened in SQL Server Management Studio and run the Transact-SQL script file (sqlcmd tool) using SQLCMD.

Running script files

Open a command Prompt window.

In the Command Prompt window, type sqlcmd-s myserver\instancename-i C:\myScript.sql

Press the Enter key.

Save this output to a text file

Open a command Prompt window.

In the Command Prompt window, type sqlcmd-s myserver\instancename-i C:\myScript.sql-o C:\EmpAdds.txt

Press the Enter key.

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.