Thursday, March 6, 2014

How to know SQL Server Version using backup file?

Backup and restore these are common tasks while working with the database. But before restoring the database it is necessary that we should know about some information about backup file because it may be possible that we have created backup file in upper version of SQL Server and we are trying to restore it in lower version of SQL Server. In this is case database can not be restored.

So before facing this problem it is better to know about backup file means in which version it was created.

To get this information we can simply use RESTORE command with HEADERONLY. Check the bellow command -


RESTORE HEADERONLY 
         FROM DISK = N'd:\filename.bak' 

By passing the path of backup file you can run this command, you will get result like this-


SqlServerBackupFileInforation1


SqlServerBackupFileInforation2


SqlServerBackupFileInforation3


SqlServerBackupFileInforation4


SqlServerBackupFileInforation5


SqlServerBackupFileInforation6

  SqlServerBackupFileInforation7


SqlServerBackupFileInforation8


By seeing SoftwareVersionMajor and SoftwareVersionMinor you can identify the version of the software.

To know about each column help follow this link-

http://technet.microsoft.com/en-us/library/ms178536.aspx

Here you will get description for each column.


Wednesday, March 5, 2014

How to avoid ContextSwitchDeadlock exception?

In some of the cases we face the problem regarding ContextSwitchDeadlock. Actually there are some causes for this exception.

You can check these causes by following this link-

http://msdn.microsoft.com/en-us/library/ms172233%28v=vs.110%29.aspx

In this article, I am explaining - "How can we avoid ContextSwitchDeadlock exception?"

To void the this exception, we need to set some setting in Visual Studio IDE, Check the below steps-

1. Click on "Debug" Menu.
2. After that Click on "Exceptions".
3. It will open one Exception window. Here expand the node- "Manage Debugging Assistants".
4. Here you will find "ContextSwitchDeadlock" CheckBox, just uncheck it.

Follow-

Debug-> Exceptions-> Manage Debugging Assistants -> ContextSwitchDeadlock

Check the below screen shot-


ContextSwitchDeadlock


Just uncheck it and again run the application, This exception will be skipped while run-time.