Is it possible to transfer tables and stored procedures to another database in Visual studio?

Donald Symmons 2,861 Reputation points

I discovered that when i added my database, I didn't use the standard to add it.
This is how I added my database:
I went to the server explorer and right-clicked on Data Connections.
Then I selected Add connection.
I then chose Microsoft SQL Server Database File (SqlClient) and
added the database file name and other details, I tested the connection and clicked OK

I should have used the Create New SQL Server Database option.

Now I have created a new database using the Create New SQL server Database option, is it possible to transfer my tables and stored procedures to this new database I created?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,352 questions
0 comments No comments
{count} votes

Accepted answer
  1. Dan Guzman 9,226 Reputation points

    Visual Studio includes a schema compare feature (part of SSDT) which allows you to compare 2 databases and selectively apply differences to the target database.

    From the main VS menu, select Tools-->SQL Server-->New Schema Comparison. Then select a source and target database connection (click browse if needed to create a new connection) and click Compare. You can then select differences to apply, including all objects for your use case.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Jingyang Li 5,891 Reputation points

    You can script out your database objects and run the script to recreate these objects in your new database by using SSMS.