5,702,067 members and growing! (15,462 online)
Email Password   helpLost your password?
Web Development » ASP.NET » General     Intermediate

Connect to SQL Express 'User Instances'

By Patrick Spieler

Manage and Profile SQL Express 'User Instances'
Windows, .NET, Visual Studio, ASP.NET, Dev

Posted: 27 Aug 2006
Updated: 27 Aug 2006
Views: 19,998
Bookmarked: 12 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
7 votes for this Article.
Popularity: 3.34 Rating: 3.96 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
1 vote, 14.3%
3
1 vote, 14.3%
4
5 votes, 71.4%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Introduction

In the free SQL Server 2005 Express Edition, you get a new connection string parameter 'User instance=true'.

"data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|people.mdf;User Instance=true"

When this parameter is specified, SQL Express will create another instance of the sqlservr.exe process on the client. This process is running in the security context of the currently logged on user. The connection object passed back to the client is connected to this new user child instance, running as a client process in the user's security context.

More details about User Instances? Read this excellent article on msdn: Working with User Instances

SQL Profiler

For monitoring purposes (what's going on under the hood, troubleshooting and more), the SQL Server Profiler acts as a big time safer. The Profiler is able to read and display all the traffic between the client (e.g. a custom-application, SQL Management Studio etc.) and the SQL Server. Just attach the Profiler to a running SQL Server instance.

But how to attach to a 'user instance', where you don't have a well known instance name?

First, query the master database from SQL Express as follows:



There you get the named pipes per instance. You get the heart-beat as well: alive or dead (if the Lifetime of a User Instance Connection has timed out; default is 60 minutes).

Second, connect with the pipe (just alive instances can be connected):



Third, get the traffic, sniff, profile...



You get the Profiler together with Workgroup-, Standard- and Enterprise edition.

SQL Server Management Studio / SQL Server Management Express

This solution will work for SQL Server Management Studio as well:


The Management Studio does display all attached Databases(in my case AspNetDB.MDF and People.MDF). - There is the free Version SQL Express Studio Management Server.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Patrick Spieler


Consultant for Trivadis AG in Switzerland.
Interested in .NET, Architectures, Patterns and Web 2.0.
Blog and articles at http://sharpcuts.blogspot.com
Occupation: Web Developer
Location: Switzerland Switzerland

Other popular ASP.NET articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
  (Refresh) 
-- There are no messages in this forum --

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 Aug 2006
Editor:
Copyright 2006 by Patrick Spieler
Everything else Copyright © CodeProject, 1999-2008
Web20 | Advertise on the Code Project