views:

704

answers:

2

I created a "Service-Based Database" (.MDF) in Visual Studio and now want to import a SQL script into it, but cannot find any way to do this:

  • I can right-click on the .mdf file and choose "New Query" but there is no place to copy in query text as in Management Studio

Does the Visual Studio 2008 Database Explorer have a way to enter or import SQL query text?

A: 

Why don't you just attach the database directly to your SQL Server (or SQLExpress) and then copy the database objects. The detach from the sql server again.

Leo Moore
+1  A: 

When you choose "New Query", the default behavior is to open the Query Editor. So you have to close the Add Table. After that, you should see a window with four panes - Diagram, Criteria, SQL and Result pane. You should be able to put your script to SQL pane and run from it. The Studio may complain about being unable to parse the script, just ignore it and hit ok, the script should run.

If you cannot see these panes, ensure you have "Query Designer" toolbar enabled and "SQL pane" button pushed.

However, I would recommend installing SQL Management Studio, there is a free express version available.

František Žiačik