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]