Look at SQL Server Object Explorer in VS 2012

In this article, we will look into a new feature of Visual Studio 2012 to connect SQL databases hosted locally or on SQL Azure using SQL Server Object Explorer. In Visual Studio 2012, we can connect to a database using Server Explorer or SQL Server Object Explorer. Using this explorer, we can perform:

  1. Connection to and browsing various objects like tables, views, functions and so on.
  2. Create\Update\Delete objects using Table Designer.
  3. Clone an existing database.

We can open this window by going to "View" -> "SQL Server Object Explorer" as shown below:

Object Explorer
      
Click on "Add SQL Server" to add an SQL Server instance.

We can add a new table using Table Designer by clicking on "Add Table" on the Tables node as shown below:

Table Designer

We need to click on Update to open the following window and select the "Update Database" button to reflect the changes done by us onto an actual database as shown below:

Update Database

We can clone a database using the following procedure:

  1. Create a blank database by clicking on "Add New Database" onto which, it needs to be cloned.
  2. Now click on "Compare Schema" by selecting the source database:

    Compare schema

  3. Select target as newly created database and click on "Compare", that shows the following differences:

    Compare

  4. Click on "Update" to clone the database, that only clones the schema, not the data.
  5. We can replicate data by selecting a table, clicking on "View Data" and clicking on "Script" as shown below:

    Table

  6. This will create Insert scripts necessary for replicating the data onto a new database:

    Insert Data

  7. We can even look at estimated and actual execution plans of a SQL query by clicking on something.

Using this feature, we can do most of our SQL Server tasks within Visual Studio 2012 itself.

Up Next
    Ebook Download
    View all
    Learn
    View all