Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS SQL Server with management studio - how to script a table with its data (as insert statements)? [duplicate]

Tags:

Possible Duplicate:
Get script of SQL Server data

I want to move some rows from 1 table (on one server) to another (on another server).

The table schema is the same, what I need to do is generate some insert statements. Is there a way to do this using some built in / best practice way?

Import / Export seems completely extreme and excessive.

Thanks in advance.

like image 395
JL. Avatar asked Feb 29 '12 13:02

JL.


People also ask

How do I create a insert script in SQL Server Management Studio?

In SSMS Object Explorer, right-click the database. From the right-click menu, go to Tasks >> Generate Scripts... In the Generate and Publish Scripts pop-up window, press Next to choose objects screen. Now, the choose objects screen, choose Select specific database objects and choose the tables you want to script.

How do I script a table with data in SQL Server?

Now right-click the database then Tasks->Generate scripts. After that a window will open. Select the database and always check "script all objects in the selected database". It will generate a script for all the tables, sp, views, functions and anything in that database.

How do I script a table in SSMS?

1- Open SQL server Management Studio. 2- Right click on the DB that contains your desired table. 3- Select "Tasks => Generate Scripts...". 4- Follow on the wizard, and choose the objects that you want to generate scripts for (Tables, Views, Stored Procedures, etc... ).

How can we create duplicate table with data in SQL Server?

Use SQL Server Management StudioIn Object Explorer, right-click Tables and select New Table. In Object Explorer right-click the table you want to copy and select Design. Select the columns in the existing table and, from the Edit menu, select Copy.


1 Answers

Right-click on the database name and choose Tasks -> Generate Scripts. On the Scripting Options screen set Script Data to true.

like image 192
Anthony Faull Avatar answered Oct 07 '22 20:10

Anthony Faull