Tuesday, January 14, 2014

Alter Database failed because a lock could not be placed on a database

I was trying to take offline my database in SQL Server but getting above error. Usually there is an open connection to a database which need to be killed.

To view connections:
EXEC sp_who2

Check for any connections open to the database and get the SPID.
Now execute:
KILL <SPID>

SPID is sql server process ID which is assigned by SQL Server when connected to database.

HTH

Monday, January 13, 2014

Change Server Name in Crystal Reports

Changing Server Name is not very obvious but very easy.

1. In field explorer, Right Click on Database Fields.















2. Click on Set DataSource Location. It will open following window

3. Expand the Properties of the existing connection and right Click on Data Source as shown below























4. Click Edit, and type in the NEW Server Name and hit enter. It will change server name for all sub reports too.

5. Test the report before moving to production.

HTH.