UPDATE [DATABASEUSERGROUP].[dbo].[tblChild] SET [Childname]='test1' WHERE id=2;

--ROLLBACK TRAN--COMMIT TRAN

Hope now you will notice your second window is lock by first update.But after change Clustered Index to ID lock behavior totally different. (Like First SQL script 01) still wondering why above lock behavior...

Friday, June 19, 2015

Today my friend ask me about backup and restore related question.While talking with him about the issue, I have decided to share this in my web log.The Question was,

“Is there have a method to RESTORE database with using T-SQL?, but you didn’t have any idea about how many data files or file groups available in given backup file.”

For my Answer was very simple,

Just open SSMS and then select database backup and change new database for your needed name and next select “Script -> New Query Editor Window” then it will generate T-SQL code for you given database backup.

But again he says, nope I have to publish T-SQL script and it should be work any database backup. Well… well now I have understand his need and given him following T-SQL script and hope it will help others as well.