SQL Server 2012 Exports data as a script

Source: Internet
Author: User
Tags one table

Previous note:

Starting with SQL Server 2008, we can easily export data scripts without resorting to stored procedures, but there is a slight difference in the process of exporting scripts for SQL Server 2012 and SQL Server 2008, which I'll explain here in more detail.

In SQL Server 2012, we can't directly find the option to script the data in the following illustration.

For SQL Server 2008来, we can in the Object Explorer in SSMS2008, right-click the database where you want to export the data, and in the menu that pops up, select the Generate Script option under tasks.

In the choice script that the script thinks of, select "script that writes data" to be true, and this is false by default.

Here's a detailed illustration of this process in SQL Server 2012.

I created a new database called Blogdb with only one table testtable and some messy test data in the table.

Right-click the database, select Tasks, and select Generate script.

Click Next.

Then click Next.

Don't worry about this time. Next, we first click on the "Advanced (A)" button.

We don't see a script like SQL Server 2008 that writes data, true and false, but there's a similar option, as shown in the following figure.

If we want to export the table structure and table script of the data, the type of the data to be scripted, from the schema only to the schema and data, click "OK".

We can keep the script to the file, save it to the Clipboard, or save it to a new query form, which I am personally accustomed to saving to the file.

Here you can modify the file save path, you can name the file, for example, I named the file as Blogdb.sql.

Then click Next.

Click Next.

Click Finish, then we go to the specified directory to find this file.

Open this file and we can see:

The script is the result we want.

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.