June 15, 2012

xp_grantlogin (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.xp_grantlogin(nvarchar @loginame
, varchar @logintype)

MetaData:

 create procedure sys.xp_grantlogin  
@loginame sysname,
@logintype varchar(5) = Null -- ignored unless 'admin'
AS
set nocount on

-- IF NAME NOT 'DOMAIN\USER', ADD DEFAULT DOMAIN --
if (charindex('\', @loginame) = 0)
begin
select @loginame = default_domain() + '\' + @loginame
end

Declare @ret int -- return value of sp call
execute @ret = sys.sp_grantlogin @loginame
if (@ret = 0 and @logintype = 'admin')
execute @ret = sys.sp_addsrvrolemember @loginame, 'sysadmin'
return (@ret)

No comments:

Post a Comment

Total Pageviews