Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

How Will You Deploy An Ssis Package In Testing, Staging & Production Environments?

Answer»

The dtutil is the command prompt utility which is USED to MANAGE SSIS packages.
This utility can copy, move, DELETE or VERIFY the existence of a package.

The dtutil is the command prompt utility which is used to manage SSIS packages.
This utility can copy, move, delete or verify the existence of a package.

2.

How Many Data Sources Are Available In Ssis?

Answer»
  • DATAREADER Source in 2005 & ADO NET Source in 2008 & above.
  • Excel Source
  • Flat File Source
  • OLE DB Source
  • Raw File Source
  • Script COMPONENT
  • XML Source.

3.

What Are Pages In Sql Server? How Many Types Of Pages Are There?

Answer»

A page in SQL Server is an 8 KB data storage AREA.
There are 8 types of pages:

  1. Data
  2. Index
  3. Text/Image
  4. Global Allocation Map, SHARED Global Allocation Map
  5. Page Free Space
  6. Index Allocation Map
  7. Bulk Changed Map
  8. DIFFERENTIAL Changed Map.

A page in SQL Server is an 8 KB data storage area.
There are 8 types of pages:

4.

How Many Types Of Internal Joins Are There In Sql Server?

Answer»

5.

What Are Row Constructors?

Answer»

NEW WAY to insert MULTIPLE records in a table with INSERT statement. ALSO known as Table Value Constructor.

New way to insert multiple records in a table with INSERT statement. Also known as Table Value Constructor.

6.

What Are The Required/mandatory Parameters That Have To Be Passed With Raiseerror Statement?

Answer»

7.

How Many Types Of Temporary Tables Are There In Sql Server?

Answer»

8.

How Many Types Of Recovery Models Are Available For A Database?

Answer»
  1. SIMPLE
  2. BULK LOGGED
  3. FULL.

9.

What Are The Steps Involved In Database Partitioning?

Answer»

This involves 4 steps:

  1. CREATE Database with different file GROUPS
  2. Create Partition FUNCTION
  3. Create Partition Scheme
  4. Create Partitioned Table or Index.

This involves 4 steps:

10.

What Output Will "select 1/2" Statement Give?

Answer»

It will GIVE ZERO.

It will give zero.

11.

What Are The Various Ssis Logging Mechanisms?

Answer»

12.

How Will You Know Index Usage On Tables?

Answer»

13.

What Is The Highest, Lowest & Default Isolation Level?

Answer»

Highest: SERIALIZABLE
LOWEST: READ UNCOMMITTED
DEFAULT: READ COMMITTED

Highest: SERIALIZABLE
Lowest: READ UNCOMMITTED
Default: READ COMMITTED

14.

What Are Acid Properties, Define Them?

Answer»

A – Atomicity (Transaction is atomic, if ONE part fails, then the entire transaction fails).
C – Consistency (Any transaction the database performs will take it from one consistent STATE to another, only VALID data will be written to the database).
I – Isolation (Other operations cannot access data that has been modified during a transaction that has not yet completed).
D – Durability (On a transaction’s success the transaction will not be lost, the transaction’s data CHANGES will survive system failure, and that all integrity constraints have been satisfied).

A – Atomicity (Transaction is atomic, if one part fails, then the entire transaction fails).
C – Consistency (Any transaction the database performs will take it from one consistent state to another, only valid data will be written to the database).
I – Isolation (Other operations cannot access data that has been modified during a transaction that has not yet completed).
D – Durability (On a transaction’s success the transaction will not be lost, the transaction’s data changes will survive system failure, and that all integrity constraints have been satisfied).

15.

How Will You Rename A Table?

Answer»

By USING sp_rename STORED PROCEDURE.

By using sp_rename stored procedure.

16.

What Is The Sequence For Logical Query Processing, What Is The Order?

Answer»

FROM, [JOIN CONDITION, JOIN TABLE ...], ON, OUTER, WHERE, GROUP BY, CUBE/ROLLUP/GROUPING SETS, HAVING, SELECT, DISTINCT, ORDER BY, TOP.

FROM, [JOIN CONDITION, JOIN TABLE ...], ON, OUTER, WHERE, GROUP BY, CUBE/ROLLUP/GROUPING SETS, HAVING, SELECT, DISTINCT, ORDER BY, TOP.

17.

What Are Integrity Constraints?

Answer»

Integrity constraints are used to ensure ACCURACY and consistency of data in a relational database. Data integrity allows to define certain data quality requirements that the data in the database needs to meet. If a user tries to insert data that doesn’t meet these requirements, the RDBMS will not allow so.
A constraint is a property assigned to a column or the set of columns in a table that prevents certain TYPES of INCONSISTENT data values from being placed in the column(s). Constraints are used to enforce the data integrity. This ensures the accuracy and RELIABILITY of the data in the database.

Integrity constraints are used to ensure accuracy and consistency of data in a relational database. Data integrity allows to define certain data quality requirements that the data in the database needs to meet. If a user tries to insert data that doesn’t meet these requirements, the RDBMS will not allow so.
A constraint is a property assigned to a column or the set of columns in a table that prevents certain types of inconsistent data values from being placed in the column(s). Constraints are used to enforce the data integrity. This ensures the accuracy and reliability of the data in the database.

18.

What Can You Do With Colasce Function?

Answer»

Returns the FIRST nonnull expression AMONG its arguments.
Syntax
COALESCE ( expression [ ,...N ] )
expression
Is an expression of any type.

Returns the first nonnull expression among its arguments.
Syntax
COALESCE ( expression [ ,...n ] )
expression
Is an expression of any type.

19.

Types Of Replication?

Answer»

MICROSOFT SQL Server 2005 provides the following types of REPLICATION for USE in distributed applications:

  • Transactional Replication
  • Merge Replication
  • Snapshot Replication.

Microsoft SQL Server 2005 provides the following types of replication for use in distributed applications:

20.

Difference Between Varchar & Varchar2?

Answer»

VARCHAR2 is specific to Oracle. MS SQL SERVER has VARCHAR & VARCHAR(MAX) data TYPES.

VARCHAR2 is specific to Oracle. MS SQL Server has VARCHAR & VARCHAR(MAX) data types.

21.

What All Indexes Can You Have In A Table?

Answer»

ONE CLUSTERED INDEX, one or more than one non-clustered index, unique index, FILTERED, SPATIAL, xml, etc.

One Clustered Index, one or more than one non-clustered index, unique index, filtered, spatial, xml, etc.

22.

How Many Non-clustered Indexes Can You Have In A Table?

Answer»

UPTO 249 non-clustered INDEXES can be CREATED in a table.

Upto 249 non-clustered indexes can be created in a table.

23.

How Would You Know That If A Cursor Is Open Or Closed?

Answer»

Answer : declare @mycursor cursor declare @FirstName VARCHAR(12) SELECT CURSOR_STATUS('variable','@mycursor') --// -2 (Not applicable) SET @mycursor = cursor for select FirstName from Person.Contact select CURSOR_STATUS('variable','@mycursor') --// -1 (The cursor is closed) open @mycursor select CURSOR_STATUS('variable','@mycursor') --// 1 (The result set of the cursor has at least one row) fetch next from @mycursor into @FirstName select CURSOR_STATUS('variable','@mycursor') --// 1 (The result set of the cursor has at least one row) close @mycursor select CURSOR_STATUS('variable','@mycursor') --// -1 (The cursor is closed) deallocate @mycursor select CURSOR_STATUS('variable','@mycursor') --// -2 (Not applicable) select CURSOR_STATUS('variable','@nocursor') --// -3 (A cursor with the specified NAME does not exist)

24.

What Are The Various Isolation Levels?

Answer»
  • READ Uncommitted Isolation LEVEL
  • Read Committed Isolation Level
  • Repeatable Read Isolation Level
  • SERIALIZABLE Isolation Level
  • Snapshot Isolation Level
  • Read Committed Snapshot Isolation Level.

25.

What Is The Scope Of A Temporary Table?

Answer»

SCOPE is LIMITED to its SESSION only.

Scope is limited to its session only.

26.

What Is A Table Called That Has ## Before Its Name, What Is Its Scope?

Answer»

Table with ## (DOUBLE pound signs) is CALLED Global TEMP table. Scope is outside the session but only TILL the original session lasts.

Table with ## (double pound signs) is called Global Temp table. Scope is outside the session but only till the original session lasts.

27.

How Can You Copy Schema From One Sql Server To Another?

Answer»

28.

How Can You Load Large Data In Sql Server?

Answer»

BulkCopy is a tool used to copy huge AMOUNT of data from tables. BULK INSERT command HELPS to IMPORTS a data file into a database table or VIEW in a user-specified format.

BulkCopy is a tool used to copy huge amount of data from tables. BULK INSERT command helps to Imports a data file into a database table or view in a user-specified format.

29.

Can Stored-procedures Be Recursive? And Upto How Much Level?

Answer»

YES, 32 LEVELS.

Yes, 32 levels.

30.

What Are The Virtual Tables In Triggers?

Answer»

The VIRTUAL TABLES in TRIGGERS are:

The virtual tables in Triggers are:

31.

How Will You Handle Exceptions In Sql Server Programming?

Answer»

By using TRY-CATCH constructs, putting our SQL statements/scripts inside the TRY BLOCK and error HANDLING in the CATCH block.

By using TRY-CATCH constructs, putting our SQL statements/scripts inside the TRY block and error handling in the CATCH block.

32.

How Many Types Of Functions (udf) Are There In Sql Server?

Answer»

SQL SERVER supports MAINLY 3 types of UDFs:

  • SCALAR FUNCTIONS
  • Inline Table-valued functions
  • Multi-statement Table-valued functions.

SQL Server supports mainly 3 types of UDFs:

33.

What New Indexes Are Introduced In Sql Server 2005 In Comparison To 2000?

Answer»

34.

What Are Cube & Rollup Sets?

Answer»

CUBE & ROLLUP are the grouping sets USED with GROUP BY CLAUSE and are very helpful in creating REPORTS.

CUBE & ROLLUP are the grouping sets used with GROUP BY clause and are very helpful in creating reports.

35.

What Should Be The Ideal Combination With In & Union (all) In Terms Of Performance?

Answer»

ANSWER : SELECT *FROM WHERE IN (SELECT… UNION SELECT…) OR SELECT * FROM WHERE IN (SELECT… UNION ALL SELECT…).

36.

Difference Between Coalesce() & Isnull()?

Answer»
  • ISNULL accepts only 2 parameters. The first parameter is checked for NULL value, if it is NULL then the second parameter is returned, otherwise it returns first parameter.
  • COALESCE accepts two or more parameters. One can apply 2 or as many parameters, but it returns only the first non NULL parameter.
  • ISNULL does not implicitly converts the datatype if both parameters datatype are different. On the other side COALESCE implicitly converts the parameters datatype in order of higher precedence.
  • SIMILAR to above point ISNULL always returns the value with datatype of first parameter. Contrary to this, COALESCE returns the datatype value according to the precedence and datatype compatibility.

37.

What Are The Multiple Ways To Execute A Dynamic Query?

Answer»

EXEC sp_executesql, EXECUTE()
EXECUTE (or EXEC) vs sp_executesql
EXECUTE:
EXECUTE executes a command string or character string WITHIN a TSQL batch, or one of the following MODULES: system stored procedure, user-defined stored procedure, scalar-valued user-defined function, or extended stored procedure. The TSQL query can be a direct string or a variable of char, varchar, nchar, or nvarchar DATA type.
sp_executesql:
sp_executesql executes a TSQL statement or batch that can be reused many times, or one that has been built dynamically. The TSQL statement or batch can contain EMBEDDED parameters. The SQL query is a Unicode string or a Unicode variable that contains a Transact-SQL statement or batch. Here the variable datatype is restricted to Unicode nchar or nvarchar only. If a Unicode constant (SQL string) is used then the it must be PREFIXED with N.

EXEC sp_executesql, EXECUTE()
EXECUTE (or EXEC) vs sp_executesql
EXECUTE:
EXECUTE executes a command string or character string within a TSQL batch, or one of the following modules: system stored procedure, user-defined stored procedure, scalar-valued user-defined function, or extended stored procedure. The TSQL query can be a direct string or a variable of char, varchar, nchar, or nvarchar data type.
sp_executesql:
sp_executesql executes a TSQL statement or batch that can be reused many times, or one that has been built dynamically. The TSQL statement or batch can contain embedded parameters. The SQL query is a Unicode string or a Unicode variable that contains a Transact-SQL statement or batch. Here the variable datatype is restricted to Unicode nchar or nvarchar only. If a Unicode constant (SQL string) is used then the it must be prefixed with N.

38.

Why You Should Not Use A Cursor? What Are Its Alternatives?

Answer»

If possible, avoid using SQL Server CURSORS. They generally use a LOT of SQL Server resources and REDUCE the performance and scalability of your applications. If you NEED to perform row-by-row operations, try to find another METHOD to perform the task. Here are some alternatives to using a cursor:

  • Use WHILE LOOPS
  • Use temp tables
  • Use derived tables
  • Use correlated sub-queries
  • Use the CASE statement
  • Perform multiple queries.

If possible, avoid using SQL Server cursors. They generally use a lot of SQL Server resources and reduce the performance and scalability of your applications. If you need to perform row-by-row operations, try to find another method to perform the task. Here are some alternatives to using a cursor:

39.

How Can You Execute A Dos Command From Sql Or Through Sql Query By Using Xp_cmdshell?

Answer»

exec xp_cmdshell 'dir c:*.exe'
xp_cmdshell {'command_string'} [, no_output]
Arguments
'command_string'
Is the command string to execute at the operating-system command shell. command_string is varchar(8000) or nvarchar(4000), with no default. command_string cannot contain more than one set of double quotation marks. A single pair of quotation marks is necessary if any spaces are PRESENT in the file PATHS or PROGRAM names referenced by command_string. If you have trouble with embedded spaces, consider using FAT 8.3 file names as a WORKAROUND.
no_output
Is an optional parameter executing the given command_string, and does not return any output to the client.

exec xp_cmdshell 'dir c:*.exe'
xp_cmdshell {'command_string'} [, no_output]
Arguments
'command_string'
Is the command string to execute at the operating-system command shell. command_string is varchar(8000) or nvarchar(4000), with no default. command_string cannot contain more than one set of double quotation marks. A single pair of quotation marks is necessary if any spaces are present in the file paths or program names referenced by command_string. If you have trouble with embedded spaces, consider using FAT 8.3 file names as a workaround.
no_output
Is an optional parameter executing the given command_string, and does not return any output to the client.

40.

Difference Between Delete & Truncate Statement? Which Statement Can Be Rollbacked?

Answer»
  • With DELETE we can provide CONDITIONAL WHERE clause to remove/delete specific rows, which is not possible with TRUNCATE.
  • TRUNCATE is faster than DELETE as Delete keeps LOG of each row it deletes in transaction logs, but truncate keeps log of only de-allocated PAGES in transaction logs.
  • Both statements can be rolled backed if provided in a transaction (BEGIN TRANS). If not then none of them can be rollbacked.
  • DELETE is DML just like INSERT, UPDATE, but TRANCATE is DDL, just like CREATE, ALTER, DROP.

41.

How Can You Execute An Sql Query From Command Prompt?

Answer»

By using OSQL & SQLCMD we can execute an SQL QUERY from command prompt.

By using OSQL & SQLCMD we can execute an sql query from command prompt.

42.

What Tools Do You Use For Performance Tuning?

Answer»

SQL SERVER 2000 includes several TOOLS you may find useful when PERFORMANCE tuning your SQL Server applications. The include:

SQL Server 2000 includes several tools you may find useful when performance tuning your SQL Server applications. The include:

43.

Difference Between Sql Server 2000 & Sql Server 2005 Features Or New Features Of 2005 Vs 2000?

Answer»
  • Ranking functions (ROW_NUMBER, RANK, DENSE_RANK, NTILE)
  • Exception handling (TRY-CATCH block)
  • CTE (Common Table EXPRESSIONS)
  • PIVOT, UNPOVIT
  • CUBE, ROLLUP & GROUPING SET
  • SYNONYMS.

44.

How To Create Temporary Table? How Do We Apply Noncluster Index? What Is Nolock? When And Where Is Nolock Applied Normally?

Answer»

Two ways of creating temporary table with non clusterindex applied on it. Also example shows how to apply "nolock". nolock is NORMALLY applied while querying on production servers. This would MAKE the records being queried sharable on the table. ie, will not prevent other queries from querying the same record parallely on same table. The RISK will be nolock might return junk data some times because the select query might be querying the table while some other insertion or updation commands are performed on the table.

CREATE TABLE #tmpTable ( OfficeName varchar(50) , officeid int , CustID int , AgentID int , mlsid varchar(4) , RequestMoreDetails int null , Emails int null ) CREATE NONCLUSTERED INDEX #IX_DW_Listings ON #DW_AllListings(AgentID) select OfficeName , officeid , o.CustID , AgentID - , o.mlsid , PrintBrochure_Views = null , RequestMoreDetails = null , Emails = null into #ForOffices from #Offices LEFT JOIN dbo.planparts WITH (NOLOCK) ON bppa.officeid = o.RID CREATE NONCLUSTERED INDEX #IX_DW_Listings ON #ForOffices(AgentID)

Two ways of creating temporary table with non clusterindex applied on it. Also example shows how to apply "nolock". nolock is normally applied while querying on production servers. This would make the records being queried sharable on the table. ie, will not prevent other queries from querying the same record parallely on same table. The risk will be nolock might return junk data some times because the select query might be querying the table while some other insertion or updation commands are performed on the table.

45.

How To Update 'yes' To 'no' And Viceversa In A Query?

Answer»

UPDATE TABLENAME set ColumnName1 = (case ColumnName1 when 'Yes' then 'No' ELSE 'Yes' end).

Update tablename set ColumnName1 = (case ColumnName1 when 'Yes' then 'No' else 'Yes' end).

46.

What Is Patindex?

Answer»

Returns the STARTING position of the first OCCURRENCE of a PATTERN in a SPECIFIED expression, or zeros if the pattern is not found.
Syntax - PATINDEX ( '%pattern%' , expression )
Eg: USE AdventureWorks;

USE AdventureWorks; GO SELECT PATINDEX('%ensure%', DocumentSummary) FROM Production.Document WHERE DocumentID = 3; GO

Returns the starting position of the first occurrence of a pattern in a specified expression, or zeros if the pattern is not found.
Syntax - PATINDEX ( '%pattern%' , expression )
Eg: USE AdventureWorks;

47.

How To Query A String Contains %?

Answer»

SELECT NAME FROM tblPlayer WHERE Name LIKE '%[''%'']'.

SELECT Name FROM tblPlayer WHERE Name Like '%[''%'']'.

48.

How To Use Sql Query To Copy Only Structure?

Answer»

SELECT * into TABLE2 from TABLE1 where 1 = 2

select * into table2 from table1 where 1 = 2

49.

What Is Tsql?

Answer»

TSQL (Transact-SQL) is a set of programming extensions from SYBASE and Microsoft that ADD several features to the Structured Query Language (SQL) including transaction control, exception and error handling, row processing, and declared variables. Microsoft's SQL Server and Sybase's SQL server SUPPORT T-SQL STATEMENTS.

TSQL (Transact-SQL) is a set of programming extensions from Sybase and Microsoft that add several features to the Structured Query Language (SQL) including transaction control, exception and error handling, row processing, and declared variables. Microsoft's SQL Server and Sybase's SQL server support T-SQL statements.