![How Can I Export SQL Server Data as INSERT INTO Statements?](https://img.php.cn/upload/article/000/000/000/173599732336294.jpg)
Exporting Data from SQL Server Using INSERT INTO
In SQL Server Management Studio, you can easily export data from a table as an INSERT INTO script for transfer to another database server. Here's how:
For SQL Server 2008 and Earlier:
- In the Object Explorer, right-click on the database you want to export data from.
- Select "Tasks" > "Generate Scripts".
- In the "Generate and Publish Scripts" wizard, select the "Tables" option.
- Choose the tables you want to include in the script.
- Under the "Advanced" tab, enable the "Script Data" option to generate INSERT INTO statements.
- Click "Next" to specify output options and generate the script.
For SQL Server 2008 R2 and Later:
- Follow steps 1 and 2 as above.
- Select "Create" > "Script Database Objects" > "Select objects to script".
- Expand the "Tables" node and select the tables you want to export.
- In the "Details" pane, scroll down to the "Types of Data to Script" section.
- Select either "Data Only", "Schema and Data", or "Schema Only" as desired.
- Click "Next" to continue and generate the script.
Using an SSMS Add-In:
You can also use the "SSMS Addin" package from Codeplex for added functionality. This package allows you to export data as INSERT INTO scripts, including features such as quick find and other options.
The above is the detailed content of How Can I Export SQL Server Data as INSERT INTO Statements?. For more information, please follow other related articles on the PHP Chinese website!