Sql Server Interview Questions and Answers (1758) - Page 44

Which of the following options can be used for viewing lock status within your computer running SQL Server?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following approach is used for Pagination in SQL server 2012?

NOTE: This is objective type question, Please click question title for correct answer.
What is the equivalent statement for IF..ELSE in SQL Server queries?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following keyword is used to return output value from stored procedure in SQL Server?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following is NOT a SQL Server 2012 new feature?

NOTE: This is objective type question, Please click question title for correct answer.
What is output for SELECT Format(getdate(), 'm', 'en-US') ?

NOTE: This is objective type question, Please click question title for correct answer.
What is the output of SELECT 'Current DATE is : ' + GETDATE() ?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following clause makes a query cost-effective ?

NOTE: This is objective type question, Please click question title for correct answer.
What is the difference between CONVERT() and TRY_CONVERT() function in SQL Server?

The new TRY_CONVERT function is very similar to the CONVERT function except that it returns NULL when the conversion cannot be completed, such as attempting to put alphabetic characters into a numeric data type. If the conversion cannot be completed because the data type of the expression is not allowed to be explicitly converted to the specified data type, an error will be thrown.

The format for the TRY_CONVERT is this:
TRY_CONVERT ( data_type [ ( length ) ], expression [, style ] )



Notice that you have the option of specifying a style as you could with the CONVERT function.

An example of its use could be to try a conversion from a string input into a datetime data type where a NULL return means the user did not provide the proper input.

DECLARE @stringparm VARCHAR(30),


@result VARCHAR(30)

SET @stringparm = '2/30/2012'

SELECT @result = CASE WHEN TRY_CONVERT (datetime, @stringparm)

IS NULL THEN 'Bad Date'

ELSE 'Good Date'

END

SELECT @result

Result:

-- -- -- -- -- -- -- -- -- --

Bad Date

How do I insert the results of the stored procedure into the table using SQL Server?”

By using INSERT...EXEC statement we can insert result set of stored procedure into a table
For example, If TableName: EMP which has columns id, anme, salary (nullable), departmentID (nullable) and procedure returns only id and name as output then

INSERT INTO TableName( id, name)
EXEC ProcedureName

Which of the following statement doesn't support OUPUT keyword?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the statement is supports COLLATE clause for converting COLLATION in SQL server

NOTE: This is objective type question, Please click question title for correct answer.
What is CHOOSE() function in SQL Server?

CHOOSE() function is very simple and it returns specified index from a list of values. If Index is numeric, it is converted to integer. On the other hand, if index is greater than the element in the list, it returns NULL.

SELECT CHOOSE ( 0, 'TRUE', 'FALSE', 'Unknown' ) AS Returns_Null;

SELECT CHOOSE ( 1, 'TRUE', 'FALSE', 'Unknown' ) AS Returns_First;
SELECT CHOOSE ( 2, 'TRUE', 'FALSE', 'Unknown' ) AS Returns_Second;
SELECT CHOOSE ( 3, 'TRUE', 'FALSE', 'Unknown' ) AS Returns_Third;
SELECT CHOOSE ( 4, 'TRUE', 'FALSE', 'Unknown' ) AS Result_NULL;

How to print the following pattern using SQL server: * * * * * * * * * * * * * * *

For the above pattern We can make use of spt_values table in master database; Otherwise we can generate the simple table too

SELECT REPLICATE( ' * ', number) CustomPattern

FROM (
SELECT distinct number
FROM master.dbo.spt_values
WHERE number between 1 and 5 and type='p'
) T



OUTPUT:
*
* *
* * *
* * * *
* * * * *

How to get the list of processes which are blocked in SQL SERVER?

There are two ways to get this sp_who and sp_who2. You cannot get any detail about the sp_who2 but its provide more information than the sp_who. And other option from which we can find which process is blocked by other process is by using Enterprise Manager or Management Studio(SSMS), these two commands work much faster and more efficiently than these GUI-based front-ends.
How to inactivate/disable Parameter in SSRS 2008 Report?

By using "Cascading Parameters " concept in the SSRS we can able to achieve the functionality of disabling/inactivating report parameters in SSRS.

For suppose we have two report parameters (@departmentIDs, @JobIDs) in the Report and you wish to first select departmentID and then want to activate the second parameter(@JobID) in the report, then we must use "Cascading Parameters " in SSRS...
Which of the following conversions is NOT allowed either implicitly or explicitly using CONVERT or CAST?

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories