How to send SQL from Visual Studio into a User Instance

I really like SQL Express user instances for prototype projects but to send plain SQL commands into them is tricky. I finally found a way:

In Visual Studio create a new SQL file or open an existing one.

With the SQL file open the connect dialog.

Connect to database from Visual Studio

The Connect Dialog will pop up.

Visual Studio 2010 Connect Dialog

Click Options.

Click the “Additional Connection Parameters” tab and type “User Instance=true”.

The connect options User Instance

Click Connect.

Select the appropriate user instance (database name looks like a file path).

Select the User Instance to connect to.

That’s it! Now you can fire plain SQL at your user instance.

Advertisements