0

What the difference between (localdb)\v11.0 and .\sqlexpress in connection string?

I am using master database file .mdf local database using SQL Server 2012

Data Source=(localdb)\v11.0; 

and

Data Source=.\sqlexpress;

What's the best or favored to use in connection string?

I try both of them in my connection string but I found or I think the v11.0 it's best than .\sqlserver is that right?

Dale K
  • 25,246
  • 15
  • 42
  • 71
KIM
  • 5
  • 3

1 Answers1

0

SQL Server Express is a service-based version of SQL Server i.e. it runs as a service all the time, independently of other applications. When you say .\SQLEXPRESS you are looking for a named instance of SQL Server called SQLEXPRESS that is on your local machine and connected to via a shared memory interface (that's what the dot is).

Local DB is a deployment option for SQL Server Express that runs as an attached process to another application, instead of as a service. It can also be started and stopped by the local db utility. Mostly it's used attached to applications like Visual Studio that just need to use a SQL Server for a while during development, but don't need it running all the time. When you connect to (localdb)\v11.0 you are connecting to one of these attached instances, and in this case using version 11 (you can have multiple versions of localdb on the same machine).

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Greg Low
  • 1,526
  • 1
  • 4
  • 4
  • Either would work OK. If you want a service running all the time (e.g. many apps talking to it), then use a SQLEXPRESS instance. If you just want to use it for development in VS, then just use localdb. – Greg Low May 18 '20 at 07:55