RSS Feed for Ms Sql Server Interview QuestionsCategory: Ms Sql Server Interview Questions

What is a LiveLock? »

A livelock is one, where a request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keeps interfering. SQL Server detects the situation after four denials and refuses further shared locks. A livelock also occurs when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely.

What is a deadlock? »

Deadlock is a situation when two processes, each having a lock on one piece of data, attempt to acquire a lock on the other’s piece. Each process would wait indefinitely for the other to release the lock, unless one of the user processes is terminated. SQL Server detects deadlocks and terminates one user’s process.

What’s the difference between DELETE TABLE and TRUNCATE TABLE commands? »

DELETE TABLE is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow. TRUNCATE TABLE also deletes all the rows in a table, but it won’t log the deletion of each row, instead it logs the deallocation of the data pages of the table, which makes [...]

How do you transfer data from text file to database (other than DTS)? »

Using the BCP (Bulk Copy Program) utility.

What are the different ways of moving data/databases between servers and databases in SQL Server? »

There are lots of options available, you have to choose your option depending upon your requirements. Some of the options you have are: BACKUP/RESTORE, detaching and attaching databases, replication, DTS, BCP, logshipping, INSERT…SELECT, SELECT…INTO, creating INSERT scripts to generate data.

What is the use of SCOPE_IDENTITY() function? »

Returns the most recently created identity value for the tables in the current execution scope.

What is the purpose of UPDATE STATISTICS? »

Updates information about the distribution of key values for one or more statistics groups (collections) in the specified table or indexed view.

How to determine the service pack currently installed on SQL Server? »

The global variable @@Version stores the build number of the sqlservr.exe, which is used to determine the service pack installed. eg: Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Enterprise Edition on Windows NT 5.0 (Build 2195: Service Pack 3)