DEV Community

Steven McLintock
Steven McLintock

Posted on

1

Auto-Generate Insert Statements With Data Using SQL Server Management Studio

If you are working with a database in SQL Server Management Studio (SSMS), you may find you need a way to auto-generate INSERT statements with the data from a table. This might be for inserting the data into a different database for testing purposes, or simply as a backup.

The Generate Scripts feature of SQL Server Management Studio will let you choose an area of the database (e.g. a table) for generating Transact-SQL scripts. It will let you choose one or more database objects and you can generate scripts for the schema, the data or both.

You can find the Generate Scripts feature in the context menu of the database. Right-click on the database, navigate to Tasks and then Generate Scripts:

Generate Scripts feature in the context menu

Click Next in the Introduction:

Introduction for Generate Scripts

In Choose Objects, choose a database object, or multiple objects:

Choose Objects for Generate Scripts

In Set Scripting Options, click Advanced:

Set Scripting Options for Generate Scripts

This is important as you can now tell the Generate Scripts feature to generate scripts for the schema, the data or both:

Advanced menu for Set Scripting Options

If you chose to generate scripts for both the schema and the data, you should see the following:

INSERT statements with data

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️