Connection string to localhost with mssql express

This one is a short one, but I’ve been asked this a lot, so here it is:

How to connect to a mssql server usually the one installed with visual studio 2010/2008.

The shortest answer:

"Data Source=.\SQLEXPRESS;Initial Catalog=[your database name];Integrated Security=True;Pooling=False"

I’ve got this from many users who tried “localhost” “.” or even nothing at all. True, there were some times that actually worked, But not in the recent versions of visual studio. Also, creating a database is now being done through the server explorer:

And you will obviously still going to need the connection string.

*You might want to check this for connection code.