1.

In SQL Server, what is the correct sequence of steps for creating a partitioned table using horizontal partitioning


 
 

  1. Create additional filegroups



  2.  
  3. Check the status of available filegroups after creation



  4.  
  5. Add .ndf file to every filegroup



  6.  
  7. Check status of files which are created and added to the filegroups



  8.  
  9. Create a partition function



  10.  
  11. Create a partition scheme using the partition function



  12.  
  13. Create the partition table using the partition scheme




  14.  
  15.  


  16.  
2.

You are checking the security of an SQL Server instance of a database. The requirements are listed as follows:


 
 

  1. Successful login attempts in the log files



  2.  
  3. Failed login attempts in the log files



  4.  
  5. The SQL Server instance is closed if the records cannot be written to the log files




  6.  
  7.  


  8.  

 
 

Which of the following commands is used to set the SQL Server sample to meet the requirements?

3.

You have created the following dbo.Emp_records procedures and you want to check if any procedure of that name exists. If it exists already, then delete the procedure and create a new one. However, the following procedure generates an error. Identify the correct code which performs the task.




 
IF EXISTS(SELECT * FROM sys.sys_files WHERE SCHEMA_ID = SCHEMA_ID('dbo')  AND name = N 'Emp_records') 
DROP PROCEDURE dbo.Emp_records 
GO 
Create Procedure dbo.Emp_records( @EmpFirstName Varchar(200), @EmpLastName  Varchar(200), @EmpEmail     Varchar(50)) 
As  Begin   Insert into tbl_Employees(Firstname, lastname, Email)   Values("@EmpFirstName", "@EmpLastName", "@EmpEmail")  End
4.

The following code was used to create a stored procedure for adding the details of a new category to the table named category:




 
CREATE PROCEDURE prcAddCategory@ CategoryId
char(3), @Category char(20), @Descrip char(30)

as

INSERT Category
VALUES(‘CategoryId’, ’Category’, ’Descrip’)

After successful creation of the following procedure the following code was used to execute the procedure
for inserting a new category:

    Exec prcAddCategory‘ 017’, ‘War Games’, ‘A wider range of toy guns’


 
 
The given code generated an error and was aborted. You need to detect the error and rectify the code.
5.

In an SQL Server, the following cursor generates a report of vendors who have sold or distributed a particular product. However, the following cursor generates an error. Rectify the error and identify the correct code. SET NOCOUNT ON;


 
 
DECLARE @v_id int, @v_name nvarchar(50),
@message varchar(80), @product nvarchar(50);

 
 
PRINT '-------- Vendor Products Report --------';
DECLARE vendor_cursor CURSOR FOR 
SELECT VendorID, Name
FROM VendorTbl
WHERE V_Status = 1
ORDER BY VendorID;
OPEN vendor_cursor
FETCH NEXT FROM vendor_cursor 
INTO @v_id, @v_name
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT ' '
SELECT @message = '----- Products From Vendor: ' + 
@v_name
PRINT@ message
DECLARE product_cursor CURSOR FOR
SELECT v.Name
FROM Prod_VendorTbl pv, ProductTbl v
WHERE pv.ProductID = v.ProductID
OPEN product_cursor
FETCH NEXT FROM product_cursor INTO@ product
IF@@ FETCH_STATUS < > 0
PRINT '         <<None>>'

WHILE@@ FETCH_STATUS = 0
BEGIN

SELECT@ message = '         ' + @product
PRINT@ message
FETCH NEXT FROM product_cursor INTO@ product
END

FETCH NEXT FROM vendor_cursor
INTO@ v_id, @v_name

 
 
END 
CLOSE vendor_cursor;
DEALLOCATE vendor_cursor;
6.
In an SQL Server, which of the following will you use to determine whether the tables contain external fragmentation?
7.

You are managing an SQL database called ContractCust, which is down. You try to restore using the following Transact-SQL script.




 
RESTORE DATABASE ContractCust FROM contracts_bu_device
WITH CONTINUE_AFTER_ERROR, CHECKSUM, RECOVERY





After the database was restored, the SQL Server logs show errors in some page restored. Which of the following codes will you use to repair the database pages, which are down, and repair it using the fastest method?
8.

You are managing two SQL servers called Tester1 and Tester2. There is a database called MyDataBase in Tester1, you decide to transfer the MyDataBase from Tester1 to Tester2. A person uses an SQL Server login named clerk with the password "p@$$w0rd" to enter the database on Tester1. You develop the same SQL Server login on Tester2. The user tries to process MyDataBase database on Tester2 by utilizing the SQL Server login clerk. However, the user gets an error message which implies that the access to the MyDataBase is not allowed. Which of the following will you use make sure that the user can process the MyDataBase database?

9.

In an SQL Server, which of the following statements are true for user-defined functions?

 

  1. User-defined functions are also used to perform actions that modify the database state.



  2.  
  3. User-defined functions cannot contain an OUTPUT INTO clause that has a table as its target.



  4.  
  5. User-defined functions cannot return multiple result sets. You need to use a stored procedure if you need to return multiple result sets.



  6.  
  7. Error handling is restricted in a user-defined function. A user-defined function does not support TRY…CATCH, @ERROR or RAISERROR.



  8.  
  9. id functions cannot call a stored procedure but can call an extended stored procedure


  10.  
10.

What is the error in the following SQL Server code:


 
 
USE EmployeeProjects2012;
GO
BEGIN DISTRIBUTED TRANSACTION;
DELETE EmployeeProjects2012.HR.JobCandidate
WHERE JobCandidateID = 13;
DELETE RemoteServer.EmployeeProjects2012.HR.JobCandidate
WHERE JobCandidateID = 13;
COMMIT TRANSACTION;
GO