Export Tables & Stored Procedures in SQL Server

There are many ways to export or import tables and procedures from one database to another database in the same server, or maybe differing servers.

Let's see the procedure to do that.

Step 1

Go to the Object Explorer window then click on something then right-click on your database then select Tasks then click on Generate Scripts as shown in the following.

Generate Scripts

Step 2

After clicking on Generate Scripts the popup is open as shown in the following and select Choose Objects.

On the right side you found tables and Stored Procedures. Expand Tables and Stored Procedures. Here you have the flexibility to export selected procedures and tables or all the tables and procedures by clicking checkboxes.

dbo

Next click on the Next button.

Step 3

In the Set Scripting Options window set the location where you want to save the generated script. In this example we are saving in a new query window. Click on the Next button.

Set Scripting Options

Step 4

Again click on the Next button in the new window.

click on Next button

Step 5

And then click on the Finish button after generating the script of the selected Stored Procedure.

click on finish button

Step 6

At this point the script is generated. Copy the generated script of tables and Stored Procedures and execute it in the database where you want to export.

execute

Note: Replace the database name (DB_Dev_USER in my sample) by your destination database name.

I hope you enjoyed it. Please provide your valuable suggestions and feedback.