Which Transact-SQL statement should you use?

You administer a Microsoft SQL Server 2012 database named ContosoDB. The database
contains a table named Suppliers and a column named IsActive in the Purchases schema
You create a new user named ContosoUser in ContosoDB. ContosoUser has no
permissions to the Suppliers table.
You need to ensure that ContosoUser can delete rows that are not active from Suppliers.
You also need to grant ContosoUser only the minimum required permissions.
Which Transact-SQL statement should you use?

You administer a Microsoft SQL Server 2012 database named ContosoDB. The database
contains a table named Suppliers and a column named IsActive in the Purchases schema
You create a new user named ContosoUser in ContosoDB. ContosoUser has no
permissions to the Suppliers table.
You need to ensure that ContosoUser can delete rows that are not active from Suppliers.
You also need to grant ContosoUser only the minimum required permissions.
Which Transact-SQL statement should you use?

A.
GRANT DELETE ON Purchases. Suppliers TC ContosoUser

B.
CREATE PROCEDURE Purchases.PurgelnactiveSuppliers
WITH EXECUTE AS USER = ‘dbo’
AS
DELETE FROM Purchases.Suppliers WHERE IsActive = 0
GO
GRANT EXECUTE ON Purchases.PurgelnactiveSuppliers TO ContosoUser

C.
GRANT SELECT ON Purchases.Suppliers TO ContosoUser

D.
CREATE PROCEDURE Purchases. PurgeInactiveSuppliers
AS
DELETE FROM Purchases.Suppliers WHERE IsActive = 0
GO
GRANT EXECUTE ON Purchases. PurgeInactiveSuppliers TO ContosoUser

Explanation:
http://msdn.microsoft.com/en-us/library/ms188354.aspx
http://msdn.microsoft.com/en-us/library/ms187926.aspx



Leave a Reply 7

Your email address will not be published. Required fields are marked *


MUSHTAQ KHAN

MUSHTAQ KHAN

The Answer is: D.

dennis

dennis

Yes, D is sufficient

Dave

Dave

But when I’ll make the exam, I’ll have to choose B or D?
In all vce that I’ve seen the answer is B (WITH EXECUTE AS USER = ‘dbo’)

Marcelo

Marcelo

Test Script:

use [AdventureWorks2012]
drop user ContosoUser;
drop proc Purchases.PurgeInactiveSuppliers;
drop table Purchases.Suppliers;
drop schema Purchases;

create schema Purchases;
create table Purchases.Suppliers (id int, IsActive int);
insert into Purchases.Suppliers select 1, 1 union all select 2, 0 union all select 2, 1;
select * from Purchases.Suppliers;

CREATE USER ContosoUser WITHOUT LOGIN
CREATE PROCEDURE Purchases.PurgeInactiveSuppliers 
AS 
DELETE FROM Purchases.Suppliers WHERE IsActive = 0;
GRANT EXECUTE ON Purchases. PurgeInactiveSuppliers TO ContosoUser;

execute as user = ‘ContosoUser’;
exec Purchases.PurgeInactiveSuppliers 
revert
select * from Purchases.Suppliers

the answer is ‘D’

Mohamed Hasan

Mohamed Hasan

Answer is D i tried it on my Computer and it works but for B it gave my error on ‘User=’dbo”