Category Archives: SQL Server

Microsoft SQL LocalDB

LocalDB was introduced in SQL Server 2012 CTP3. It’s basically a new version of SQL Express, with same functionality, dedicated to developers. So you don’t need to install any SQL server. If you have installed SQL 2012 or Visual Studio 11 then you already have it, and it runs over .Net 4 or higher. If you are using Visual Studio 11 and have been playing with the new EntityFramework and MVC, you can see it on the default connection string.
When you start a debug session the LocalDB starts on a different process with a clean instance of SQL. When you stop the debug session, it stops. And this is quite fun sinceyou get a full local dedicated database per debug session started and stopes by VS. The LocalDB also support Database as a file during the connection process letting the developers work on local MDF/LDF file.
  1. LocalDB uses the same sqlservr.exe as the regular SQL Express and other editions of SQL Server. The application is using the same client-side providers (ADO.NET, ODBC, PDO and others) to connect to it and operates on data using the same T-SQL language as provided by SQL Express.
  2. LocalDB is installed once on a machine (per major SQL Server version). Multiple applications can start multiple LocalDB processes, but they are all started from the same sqlservr.exe executable file from the same disk location.
  3. LocalDB doesn’t create any database services; LocalDB processes are started and stopped automatically when needed. The application is just connecting to “Data Source=(localdb)v11.0″ and LocalDB process is started as a child process of the application. A few minutes after the last connection to this process is closed the process shuts down.
  4. LocalDB connections support AttachDbFileName property, which allows developers to specify a database file location. LocalDB will attach the specified database file and the connection will be made to it.
If you have an instance of SQL Server 2008 or Visual Studio 2010 than you cannot connect to this database. You can only connect using SQL 2012 or VS 11

You can download LocalDB from this page. And as I mentioned above – get the full functionality of SQL Express (Linq, XML, ADO .Net, Spatial Types, SP, T-SQL). It will only work with local connections, does not run on mobile devices and the DB size is limited to 10GB (1 CPU).

How to Rename SQL Server

In case of server migrations or if you are in a situation to rename the physical server hosting SQL Server, Renaming SQL Server to host the new physical server name is pretty simple as done below

MSDN Reference for Add Server http://msdn.microsoft.com/en-us/library/ms174411.aspx

This procedure must be executed on all instances of the Database Engine hosted on the computer but the instance name of the Database Engine cannot be changed. On the SQL Server instance, run the following query:

sp_dropserver ‘<oldservername>’
go

sp_addserver ‘<newservername>’, local
go

Now restart the SQL Server related services. Then, the command below to verify if the new name has been updated.

select @@servername