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

How do you debug the stored procedure?

Old is Gold
--------------

By using the Print() command of TSQL

Since Sql Server 2008
------------------------

From SSMS,we can start the debugger by either clicking the Debug button on the Query toolbar or by clicking Start Debugging on the Debug menu or pressing ALT+F5.

From Visual Studio 2010
---------------------------

Step 1: Open Server Explorer -> Server nodes-> SQL Server machine name -> SQL Servers node -> SQL Server instance -> Your database node -> stored procedures node.

Step 2: Right-click YOUR stored procedure and then click Step Into Stored Procedure.

Step 3: Press F11 to step through the stored procedure.
What will be the output of SELECT CAST(ROUND(123456789.987654321, 2, 1) AS DECIMAL(18, 2))

NOTE: This is objective type question, Please click question title for correct answer.
What will be the output of declare @str as varchar(100) set @str = 'Where are you now?' select REPLACE(@str,' ' ,'')

NOTE: This is objective type question, Please click question title for correct answer.
What will be the output of SELECT 'RNA''s'

NOTE: This is objective type question, Please click question title for correct answer.
What will be the output of SELECT REPLICATE ('DNF ', 5)

NOTE: This is objective type question, Please click question title for correct answer.
What will be the output of PRINT 'DNF ' GO 5

NOTE: This is objective type question, Please click question title for correct answer.
What will the below command do? EXEC xp_cmdshell 'RENAME D:\onlytest RenamedFolderonlytest'

NOTE: This is objective type question, Please click question title for correct answer.
What will be the output of Select Patindex('%[0-9]%',REVERSE(REVERSE(NEWID())))

NOTE: This is objective type question, Please click question title for correct answer.
What the below code is performing? USE msdb EXEC msdb..sp_send_dbmail @profile_name='Test Cient', @recipients='receipent1@yopmail.com;receipent2@yopmail.com', @subject='Daily File Report', @body= 'Please find enclosed the daily file report', @file_attachments='D:\FileToExport.txt'

The above code will send email using the sp_send_dbmail of MSDB which will reach to the recipients receipent1@yopmail.com;receipent2@yopmail.com with the subject as 'Daily File Report' , the body being 'Please find enclosed the daily file report' and a file attachment 'D:\FileToExport.txt'
Why it is said to avoid WHILE Loops in SQL Server?

In the case of While loops the rows are rows are processed one after another and hence if we want to submit any job(s) to the query engine, it process in a sequential manner.Where as if we can re-write the same query by using in a SET Based manner, we can submit a complete batch of job(s) to the query engine which on the other hand will be processed much faster way.
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