June 8, 2012

sp_setapprole (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_setapprole(nvarchar @rolename
, nvarchar @password
, varchar @encrypt
, bit @fCreateCookie)

MetaData:

 create procedure sys.sp_setapprole  
@rolename sysname, -- name app role
@password sysname, -- password for app role
@encrypt varchar(10) = 'none', -- Encryption style ('none' | 'odbc')
@fCreateCookie bit = 0,
@cookie varbinary(8000) = 0xFFFFFFFF OUTPUT
as
-- SETUP RUNTIME OPTIONS / DECLARE VARIABLES --
set nocount on

-- DISALLOW USER TRANSACTION --
set implicit_transactions off
if (@@trancount > 0)
begin
raiserror(15002,-1,-1,'sys.sp_setapprole')
return (1)
end

-- CHECK PARAMETER
if (@rolename is null)
begin
raiserror(15431,-1,-1)
return (1)
end

-- VALIDATE ENCRYPTION
declare @encrStyle int
select @encrStyle = case lower(@encrypt) when 'none' then 0 when 'odbc' then 1 else null end
if (@encrStyle is null)
begin
raiserror(15600,-1,-1,'sys.sp_setapprole')
return (1)
end

-- SP MUST BE CALLED AT ADHOC LEVEL --
if (@@nestlevel > 1)
begin
raiserror(15422,-1,-1)
return (1)
end

-- ACTIVATE APPROLE (THIS IS ONLY VALID FROM THIS SP!) --
if (@fCreateCookie = 1)
setuser @rolename, @password, @encrStyle, @cookie
else
setuser @rolename, @password, @encrStyle

-- RETURN SUCCESS/FAILURE --
if (@@error <> 0)
return (1)
return (0) -- sp_setapprole

No comments:

Post a Comment

Total Pageviews