June 6, 2012

sp_publicationsummary (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_publicationsummary(nvarchar @publication
, nvarchar @publisher)

MetaData:

   
CREATE PROCEDURE sys.sp_publicationsummary
(
@publication sysname,
@publisher sysname = NULL
)
AS
BEGIN
DECLARE @cmd nvarchar(4000),
@retcode int,
@publisher_type sysname

EXEC @retcode = sys.sp_MSrepl_getpublisherinfo @publisher = @publisher,
@rpcheader = @cmd OUTPUT,
@publisher_type = @publisher_type OUTPUT

IF @retcode <> 0
BEGIN
RETURN (@retcode)
END

select @publisher = UPPER(@publisher)
,@cmd = @cmd + N'sys.sp_MSrepl_publicationsummary'

EXEC @retcode = @cmd
@publication,
@publisher,
@publisher_type

RETURN (@retcode)
END

sp_publication_validation (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_publication_validation(nvarchar @publication
, smallint @rowcount_only
, tinyint @full_or_fast
, bit @shutdown_agent
, nvarchar @publisher)

MetaData:

   
CREATE PROCEDURE sys.sp_publication_validation
(
@publication sysname, -- publication name --
@rowcount_only smallint = 1, -- type of check requested --
@full_or_fast tinyint = 2, -- full (0) fast (1), or conditional fast (2) method to calculate rowcount --
@shutdown_agent bit = 0, -- shut down agent after validation if 1 --
@publisher sysname = NULL -- only non-null for heterogeneous publishers --
)
AS
BEGIN
DECLARE @cmd nvarchar(4000)
DECLARE @retcode int
DECLARE @publisher_type sysname

SET @retcode = 0


-- Security Check
-- No reason anyone but Sysadmin or dbo of publishing db should run this
exec @retcode = sys.sp_MSreplcheck_publish
if @@error <> 0 or @retcode <> 0
begin
return (1)
end

EXEC @retcode = sys.sp_MSrepl_getpublisherinfo @publisher = @publisher,
@publisher_type = @publisher_type OUTPUT,
@rpcheader = @cmd OUTPUT

IF @retcode <> 0
RETURN (@retcode)

if (@publisher_type = 'MSSQLSERVER')
begin

SET @cmd = @cmd + N'dbo.sp_MSpublication_validation '

EXEC @retcode = @cmd
@publication,
@rowcount_only,
@full_or_fast,
@shutdown_agent

end
else
begin
-- Heterogeneous articles are handled directly by sp_IHpublication_validation
SET @publisher = UPPER(@publisher) COLLATE DATABASE_DEFAULT
set @cmd = @cmd + N'sys.sp_IHpublication_validation '

EXEC @retcode = @cmd
@publication,
@rowcount_only,
@full_or_fast,
@shutdown_agent,
@publisher
end

RETURN (@retcode)
END

sp_processlogshippingmonitorsecondary (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_processlogshippingmonitorsecondary(tinyint @mode
, nvarchar @secondary_server
, nvarchar @secondary_database
, uniqueidentifier @secondary_id
, nvarchar @primary_server
, nvarchar @monitor_server
, bit @monitor_server_security_mode
, nvarchar @primary_database
, int @restore_threshold
, int @threshold_alert
, bit @threshold_alert_enabled
, nvarchar @last_copied_file
, datetime @last_copied_date
, datetime @last_copied_date_utc
, nvarchar @last_restored_file
, datetime @last_restored_date
, datetime @last_restored_date_utc
, int @last_restored_latency
, int @history_retention_period)

MetaData:

 create procedure sys.sp_processlogshippingmonitorsecondary   
(
@mode tinyint -- 1 = add, 2 = delete, 3 = update
,@secondary_server sysname
,@secondary_database sysname = NULL
,@secondary_id uniqueidentifier
,@primary_server sysname = NULL
,@monitor_server sysname
,@monitor_server_security_mode bit
,@primary_database sysname = NULL
,@restore_threshold int = NULL
,@threshold_alert int = NULL
,@threshold_alert_enabled bit = NULL
,@last_copied_file nvarchar(500) = NULL
,@last_copied_date datetime = NULL
,@last_copied_date_utc datetime = NULL
,@last_restored_file nvarchar(500) = NULL
,@last_restored_date datetime = NULL
,@last_restored_date_utc datetime = NULL
,@last_restored_latency int = NULL
,@history_retention_period int = NULL
)
as
begin
set nocount on
declare @retcode int

--
-- security check
--
exec @retcode = sys.sp_MSlogshippingsysadmincheck
if (@retcode != 0 or @@error != 0)
return 1
--
-- This should be called only on the remote monitor server
--
if (@monitor_server is null or upper(@monitor_server) != upper(@@servername)
or upper(@monitor_server) = upper(@secondary_server))
return 0
--
-- must be invoked from MSDB
--
if (db_name() != N'msdb')
begin
raiserror (21482, 16, -1, N'sp_processlogshippingmonitorsecondary', N'msdb')
return 1
end
--
-- call the internal proc now
--
exec @retcode = sys.sp_MSprocesslogshippingmonitorsecondary @mode = @mode
,@secondary_server = @secondary_server
,@secondary_database = @secondary_database
,@secondary_id = @secondary_id
,@primary_server = @primary_server
,@monitor_server = @monitor_server
,@monitor_server_security_mode = @monitor_server_security_mode
,@primary_database = @primary_database
,@restore_threshold = @restore_threshold
,@threshold_alert = @threshold_alert
,@threshold_alert_enabled = @threshold_alert_enabled
,@last_copied_file = @last_copied_file
,@last_copied_date = @last_copied_date
,@last_copied_date_utc = @last_copied_date_utc
,@last_restored_file = @last_restored_file
,@last_restored_date = @last_restored_date
,@last_restored_date_utc = @last_restored_date_utc
,@last_restored_latency = @last_restored_latency
,@history_retention_period = @history_retention_period
if (@retcode != 0 or @@error != 0)
return 1
--
-- all done
--
return 0
end

sp_publisherproperty (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_publisherproperty(nvarchar @publisher
, nvarchar @propertyname
, nvarchar @propertyvalue)

MetaData:

   
--
-- Name:
-- sp_publisherproperty
--
-- Description:
-- Displays or changes publisher properties. sp_publisherproperty should only be
-- used for heterogeneous publishers.
--
-- Inputs:
-- @publisher == name of heterogeneous publisher
-- @propertyname == property name
-- @propertyvalue == property value
--
-- Returns:
-- Return code (0 for success, 1 for failure)
--
-- Security:
-- public -- call must be sysadmin
--
-- Notes:
-- If publisher is the only supplied parameter, the result set include the
-- current settings for all of the settable properties. If property name is
-- as well, only the named property appears in the result set. If value is
-- supplied, sp_publisherproperty does not return a result set.
--
-- Properties: Description
--
-- xactsetbatching When set to enabled, both the heterogeneous log reader
-- and the xactset job are able to group changes into
-- transactionally consistent sets for subsequent processing
-- by the log reader. When set to disable, the log reader can
-- process existing xactsets, but neither the log reader not the
-- xactset job may create additional sets. By default, xactset
-- batching is set to enabled at the publisher.
--
-- xactsetjob When set to enabled, the xactset job runs periodically to create
-- xactsets at the publisher for subsequent processing by the
-- log reader. When set to disabled, the creation of xactsets is
-- only done by the log reader when it polls the publisher for
-- change commands. The xactset job does not run. By default, the
-- xactset job is set to disabled at the publisher.
--
-- xactsetjobinterval Interval between successive executions of the xactset job in
-- minutes.
--

CREATE PROCEDURE sys.sp_publisherproperty
(
@publisher sysname,
@propertyname sysname = NULL,
@propertyvalue sysname = NULL
)
AS
BEGIN
DECLARE @cmd nvarchar(4000)
DECLARE @cmd2 nvarchar(4000)
DECLARE @retcode int
DECLARE @publisher_type sysname
DECLARE @jobenabled bit
DECLARE @batchenabled bit
DECLARE @interval int

SET @jobenabled = 0
SET @batchenabled = 0
SET @interval = 0

-- Security Check: requires sysadmin, done in sp_MSrepl_getpublisherinfo

SET @retcode = 0

EXEC @retcode = sys.sp_MSrepl_getpublisherinfo @publisher = @publisher,
@rpcheader = @cmd OUTPUT,
@publisher_type = @publisher_type OUTPUT,
@hreplOnly = 1

IF @retcode <> 0
RETURN (@retcode)

-- Error if the publisher is not an Oracle publisher
IF @publisher_type NOT LIKE 'ORACLE%'
BEGIN
RAISERROR (21687, 16, -1, @publisher, @publisher_type)
RETURN (1)
END

-- If propertyname is NULL, propertyvalue must be NULL as well
IF @propertyname IS NULL and @propertyvalue IS NOT NULL
BEGIN
-- Nothing to do - just leave
RETURN (0)
END

-- If propertyname is NULL return values for all of the settable properties
IF @propertyname IS NULL
BEGIN
create table #properties
(
propertyname sysname,
propertyvalue sysname
)

-- Return parity of xactsetbatching flag
set @cmd2 = @cmd
set @cmd2 = @cmd2 + N'sys.sp_ORAhelpXactBatching'

EXEC @retcode = @cmd2 @publisher,
@enabled = @batchenabled OUTPUT

if @retcode <> 0 or @@error <> 0
RETURN(1)

-- Return parity of xactset job flag and job interval
set @cmd2 = @cmd
set @cmd2 = @cmd2 + N'sys.sp_ORAhelpXactSetJob'

EXEC @retcode = @cmd2 @publisher,
@interval = @interval OUTPUT,
@enabled = @jobenabled OUTPUT

if @retcode <> 0 or @@error <> 0
RETURN(1)

-- Return result set
INSERT INTO #properties
VALUES(
N'xactsetbatching',
CASE isnull(@batchenabled,0)
WHEN 1 THEN N'enabled'
WHEN 0 THEN N'disabled'
END
)
INSERT INTO #properties
VALUES(
N'xactsetjob',
CASE isnull(@jobenabled,0)
WHEN 1 THEN N'enabled'
WHEN 0 THEN N'disabled'
END
)
INSERT INTO #properties
VALUES(
N'xactsetjobinterval',
CONVERT(NVARCHAR(20),@interval)
)

-- return result set
SELECT * FROM #properties

RETURN (0)
END

-- Validate property name
IF @propertyname NOT IN (N'xactsetbatching', N'xactsetjob', N'xactsetjobinterval')
BEGIN
RAISERROR (21794, 16, -1, '''xactsetbatching'',''xactsetjob'', and ''xactsetjobinterval''')
RETURN (1)
END

-- Process xactsetbatching
IF @propertyname = 'xactsetbatching'
BEGIN
-- If propertyvalue is NULL, return property value
IF @propertyvalue IS NULL
BEGIN
-- Return parity of xactsetbatching flag
set @cmd = @cmd + N'sys.sp_ORAhelpXactBatching'

EXEC @retcode = @cmd @publisher,
@enabled = @batchenabled OUTPUT

if @retcode <> 0 or @@error <> 0
RETURN(1)

-- Return result set
select @propertyname as N'propertyname',
CASE isnull(@batchenabled,0)
WHEN 1 THEN N'enabled'
WHEN 0 THEN N'disabled'
END as N'propertyvalue'

RETURN (@retcode)
END

-- If set, property value must be either enable or disabled
IF @propertyvalue NOT IN (N'enabled', N'disabled')
BEGIN
RAISERROR (21795, 16, -1, '''xactsetbatching''', '''enabled'' and ''disabled''')
RETURN (1)
END

IF @propertyvalue = N'enabled'
SET @batchenabled = 1
ELSE
SET @batchenabled = 0

set @cmd = @cmd + N'sys.sp_ORASetXactBatching'

EXEC @retcode = @cmd @publisher,
@enabled = @batchenabled

RETURN (@retcode)

END

-- Process xactsetjob
IF @propertyname = N'xactsetjob'
BEGIN

-- If propertyvalue is NULL, return property value
IF @propertyvalue IS NULL
BEGIN
-- Return parity of xactsetjob flag
set @cmd = @cmd + N'sys.sp_ORAhelpXactSetJob'

EXEC @retcode = @cmd @publisher,
@enabled = @jobenabled OUTPUT

if @retcode <> 0 or @@error <> 0
RETURN(1)

-- Return result set
select @propertyname as N'propertyname',
CASE isnull(@jobenabled,0)
WHEN 1 THEN N'enabled'
WHEN 0 THEN N'disabled'
END as N'propertyvalue'

RETURN (@retcode)
END

-- If set, property value must be either enable or disabled
IF @propertyvalue NOT IN (N'enabled', N'disabled')
BEGIN
RAISERROR (21795, 16, -1, '''xactsetjob''', '''enabled'' and ''disabled''')
RETURN (1)
END

IF @propertyvalue = N'enabled'
SET @jobenabled = 1
ELSE
SET @jobenabled = 0

set @cmd = @cmd + N'sys.sp_ORAXactSetJob'

EXEC @retcode = @cmd @publisher,
@enabled = @jobenabled

RETURN (@retcode)

END

-- Process xactsetjobinterval
IF @propertyname = N'xactsetjobinterval'
BEGIN
-- If propertyvalue is NULL, return property value
IF @propertyvalue IS NULL
BEGIN
-- Return xactset job interval
set @cmd = @cmd + N'sys.sp_ORAhelpXactSetJob'

EXEC @retcode = @cmd @publisher,
@interval = @interval OUTPUT

if @retcode <> 0 or @@error <> 0
RETURN(1)

-- Return result set
select @propertyname as N'propertyname',
CONVERT(NVARCHAR(20),@interval) as N'propertyvalue'

RETURN (@retcode)
END

-- If set, property value must be a number greater than or equal to 0
SET @interval = CONVERT(int,@propertyvalue)
IF @interval < 0
BEGIN
RAISERROR (21796, 16, -1)
RETURN (1)
END

set @cmd = @cmd + N'sys.sp_ORAXactSetJob'

EXEC @retcode = @cmd @publisher,
NULL,
@interval,
0,
@interval,
0
RETURN (@retcode)

END

RETURN (@retcode)
END

sp_publishdb (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_publishdb(nvarchar @dbname
, nvarchar @value)

MetaData:

   
-- For backward compatible --
create procedure sys.sp_publishdb @dbname sysname,@value nvarchar (5)
AS

DECLARE @retcode int

EXECUTE @retcode = sys.sp_replicationdboption @dbname, 'publish', @value

IF @@ERROR <> 0 or @retcode <> 0
BEGIN
RETURN (1)
END

RETURN(0)

sp_provider_types_100_rowset (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_provider_types_100_rowset(smallint @data_type
, tinyint @best_match)

MetaData:

   
create procedure sys.sp_provider_types_100_rowset
(
@data_type smallint = null,
@best_match tinyint = null
)
as
select
TYPE_NAME = s_ptv.TYPE_NAME,
DATA_TYPE = s_ptv.DATA_TYPE, -- Used by Katmai clients
COLUMN_SIZE = s_ptv.COLUMN_SIZE,
LITERAL_PREFIX = s_ptv.LITERAL_PREFIX,
LITERAL_SUFFIX = s_ptv.LITERAL_SUFFIX,
CREATE_PARAMS = s_ptv.CREATE_PARAMS,
IS_NULLABLE = s_ptv.IS_NULLABLE,
CASE_SENSITIVE = s_ptv.CASE_SENSITIVE,
SEARCHABLE = s_ptv.SEARCHABLE,
UNSIGNED_ATTRIBUTE = s_ptv.UNSIGNED_ATTRIBUTE,
FIXED_PREC_SCALE = s_ptv.FIXED_PREC_SCALE,
AUTO_UNIQUE_VALUE = s_ptv.AUTO_UNIQUE_VALUE,
LOCAL_TYPE_NAME = s_ptv.LOCAL_TYPE_NAME,
MINIMUM_SCALE = s_ptv.MINIMUM_SCALE,
MAXIMUM_SCALE = s_ptv.MAXIMUM_SCALE,
GUID = s_ptv.GUID,
TYPELIB = s_ptv.TYPELIB,
VERSION = s_ptv.VERSION,
IS_LONG = s_ptv.IS_LONG,
BEST_MATCH = s_ptv.BEST_MATCH,
IS_FIXEDLENGTH = s_ptv.IS_FIXEDLENGTH
from
sys.spt_provider_types_view s_ptv
where
(@data_type is null or s_ptv.DATA_TYPE = @data_type) and
(@best_match is null or s_ptv.BEST_MATCH = @best_match)
order by 2

sp_provider_types_rowset (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_provider_types_rowset(smallint @data_type
, tinyint @best_match)

MetaData:

   
create procedure sys.sp_provider_types_rowset
(
@data_type smallint = null,
@best_match tinyint = null
)
as
select
TYPE_NAME = s_ptv.TYPE_NAME,
DATA_TYPE = s_ptv.DATA_TYPE_28, -- for backward compatibility
COLUMN_SIZE = s_ptv.COLUMN_SIZE_28, -- for backward compatibility
LITERAL_PREFIX = s_ptv.LITERAL_PREFIX,
LITERAL_SUFFIX = s_ptv.LITERAL_SUFFIX,
CREATE_PARAMS = s_ptv.CREATE_PARAMS_90,
IS_NULLABLE = s_ptv.IS_NULLABLE,
CASE_SENSITIVE = s_ptv.CASE_SENSITIVE,
SEARCHABLE = s_ptv.SEARCHABLE,
UNSIGNED_ATTRIBUTE = s_ptv.UNSIGNED_ATTRIBUTE,
FIXED_PREC_SCALE = s_ptv.FIXED_PREC_SCALE,
AUTO_UNIQUE_VALUE = s_ptv.AUTO_UNIQUE_VALUE,
LOCAL_TYPE_NAME = s_ptv.LOCAL_TYPE_NAME,
MINIMUM_SCALE = s_ptv.MINIMUM_SCALE_90,
MAXIMUM_SCALE = s_ptv.MAXIMUM_SCALE_90,
GUID = s_ptv.GUID,
TYPELIB = s_ptv.TYPELIB,
VERSION = s_ptv.VERSION,
IS_LONG = s_ptv.IS_LONG,
BEST_MATCH = s_ptv.BEST_MATCH_28,
IS_FIXEDLENGTH = s_ptv.IS_FIXEDLENGTH_90
from
sys.spt_provider_types_view s_ptv
where
(@data_type is null or s_ptv.DATA_TYPE_28 = @data_type) and
(@best_match is null or s_ptv.BEST_MATCH_28 = @best_match)
order by 2, 20, 19, 8 -- Adding BEST_MATCH, IS_LONG and CASE_SENSITIVE to workaround a bug in DTS wizard (see SQL BU 372342)

sp_provider_types_90_rowset (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_provider_types_90_rowset(smallint @data_type
, tinyint @best_match)

MetaData:

   
create procedure sys.sp_provider_types_90_rowset
(
@data_type smallint = null,
@best_match tinyint = null
)
as
select
TYPE_NAME = s_ptv.TYPE_NAME,
DATA_TYPE = s_ptv.DATA_TYPE_90, -- Used by Yukon clients
COLUMN_SIZE = s_ptv.COLUMN_SIZE,
LITERAL_PREFIX = s_ptv.LITERAL_PREFIX,
LITERAL_SUFFIX = s_ptv.LITERAL_SUFFIX,
CREATE_PARAMS = s_ptv.CREATE_PARAMS_90,
IS_NULLABLE = s_ptv.IS_NULLABLE,
CASE_SENSITIVE = s_ptv.CASE_SENSITIVE,
SEARCHABLE = s_ptv.SEARCHABLE,
UNSIGNED_ATTRIBUTE = s_ptv.UNSIGNED_ATTRIBUTE,
FIXED_PREC_SCALE = s_ptv.FIXED_PREC_SCALE,
AUTO_UNIQUE_VALUE = s_ptv.AUTO_UNIQUE_VALUE,
LOCAL_TYPE_NAME = s_ptv.LOCAL_TYPE_NAME,
MINIMUM_SCALE = s_ptv.MINIMUM_SCALE_90,
MAXIMUM_SCALE = s_ptv.MAXIMUM_SCALE_90,
GUID = s_ptv.GUID,
TYPELIB = s_ptv.TYPELIB,
VERSION = s_ptv.VERSION,
IS_LONG = s_ptv.IS_LONG,
BEST_MATCH = s_ptv.BEST_MATCH_90,
IS_FIXEDLENGTH = s_ptv.IS_FIXEDLENGTH_90
from
sys.spt_provider_types_view s_ptv
where
(@data_type is null or s_ptv.DATA_TYPE_90 = @data_type) and
(@best_match is null or s_ptv.BEST_MATCH_90 = @best_match)
order by 2

sp_prop_oledb_provider (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_prop_oledb_provider(nvarchar @p1)

MetaData:

 create proc sys.sp_prop_oledb_provider (  
@p1 nvarchar(255)=NULL)
as
begin

IF (not is_srvrolemember(N'setupadmin') = 1)
begin
raiserror(15003,-1,-1, N'setupadmin')
return (1)
end
exec sys.xp_prop_oledb_provider @p1
end

sp_procoption (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_procoption(varchar @OptionName
, varchar @OptionValue
, nvarchar @ProcName)

MetaData:

 create procedure sys.sp_procoption  
@ProcName nvarchar(776)
,@OptionName varchar(35)
,@OptionValue varchar(12)
as
-- DECLARE VARIABLES
declare @tabid int
,@uid int
,@opt_value int
,@opt_flag bit
,@dbname sysname

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

-- VALIDATE OPTION NAME AND VALUE
select @opt_flag =
case
when (lower(@OptionValue) in ('1' ,'on' ,'yes' ,'true')) then 1
when (lower(@OptionValue) in ('0' ,'off' ,'no' ,'false')) then 0
end
if (@opt_flag is null) OR (isnull(lower(@OptionName), '') <> 'startup')
begin
raiserror(15600,-1,-1, 'sys.sp_procoption')
return @@error
end

-- RESOLVE GIVEN OBJECT NAME --
select @tabid = object_id, @uid = schema_id from sys.objects
where object_id = object_id(@ProcName, 'local') and type in ('X','P','PC')

if @tabid is null
begin
raiserror(15165,-1,-1,@ProcName)
return @@error
end

BEGIN TRANSACTION

-- LOCK PROC & CHECK PERMISSION --
EXEC %%Object(MultiName = @ProcName).LockMatchID(ID = @tabid, Exclusive = 1, BindInternal = 0)
if @@error <> 0
begin
ROLLBACK TRANSACTION
raiserror(15165,-1,-1,@ProcName)
return @@error
end

-- MUST BE sysadmin (Startup-procs run as sysadmin) --
if is_srvrolemember('sysadmin') = 0
begin
-- In case of failure Audit the event. Note in case of success the event will be audited when we lock the
-- the object in exclusive mode and evaluate the permissions again through the security manager.
if not (@tabid is null)
begin
EXEC %%System().AuditEvent(ID = 1128350287, Success = 0, TargetLoginName = NULL, TargetUserName = NULL, Role = NULL, Object = @ProcName, Provider = NULL, Server = NULL)
end
ROLLBACK TRANSACTION
raiserror(15165,-1,-1,@ProcName)
return @@error
end

-- STARTUP PROC MUST BE OWNED BY DBO IN MASTER --
if (db_id() <> 1 OR @uid <> 1)
begin
ROLLBACK TRANSACTION
raiserror(15398,-1,-1)
return @@error
end

-- VALID OBJECT IN DATABASE? --
if @tabid is null
begin
ROLLBACK TRANSACTION
select @dbname = db_name()
raiserror(15009,-1,-1 ,@ProcName, @dbname)
return @@error
end

-- PROC CANNOT HAVE PARAMETERS --
if exists ( select * from sys.parameters where object_id = @tabid )
begin
ROLLBACK TRANSACTION
raiserror(15399,-1, -1)
return @@error
end

EXEC %%Module(ID = @tabid).SetStartup(Value = @opt_flag)

-- Set Config option for startup procs
set @opt_value =
case when exists (select * from sys.objects where type in ('X','P','PC')
and ObjectProperty(object_id, 'ExecIsStartup') = 1)
then 1 else 0 end
EXEC %%ServerConfiguration(ConfigID = 1547).SetValue(Value = @opt_value)

-- EMDEventType(x_eet_AlterProc), EMDUniversalClass(x_eunc_Table), src major id, src minor id, src name
-- -1 means ignore target stuff, target major id, target minor id, target name,
-- # of parameters, 5 parameters
EXEC %%System().FireTrigger(ID = 52, ID = 1, ID = @tabid, ID = 0, Value = @ProcName,
ID = -1, ID = 0, ID = 0, Value = NULL, ID = 3,
Value = @ProcName, Value = @OptionName, Value = @OptionValue, Value = NULL, Value = NULL, Value = NULL, Value = NULL)

-- Commit and reconfigure
COMMIT TRANSACTION
RECONFIGURE WITH OVERRIDE

-- RETURN SUCCESS
RETURN 0 -- sp_procoption

sp_processlogshippingretentioncleanup (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_processlogshippingretentioncleanup(uniqueidentifier @agent_id
, tinyint @agent_type
, nvarchar @monitor_server
, bit @monitor_server_security_mode
, int @history_retention_period
, datetime @curdate_utc)

MetaData:

 create procedure sys.sp_processlogshippingretentioncleanup   
(
@agent_id uniqueidentifier
,@agent_type tinyint -- 0 = backup, 1 = copy, 2 = restore
,@monitor_server sysname
,@monitor_server_security_mode bit
,@history_retention_period int
,@curdate_utc datetime
)
as
begin
set nocount on
declare @retcode int

--
-- security check
--
exec @retcode = sys.sp_MSlogshippingsysadmincheck
if (@retcode != 0 or @@error != 0)
return 1
--
-- This should be called only on the remote monitor server
--
if (@monitor_server is null or upper(@monitor_server) != upper(@@servername))
return 0
--
-- must be invoked from MSDB
--
if (db_name() != N'msdb')
begin
raiserror (21482, 16, -1, N'sp_processlogshippingretentioncleanup', N'msdb')
return 1
end
--
-- call the internal proc now
--
exec @retcode = sys.sp_MSprocesslogshippingretentioncleanup
@agent_id = @agent_id
,@agent_type = @agent_type
,@monitor_server = @monitor_server
,@monitor_server_security_mode = @monitor_server_security_mode
,@history_retention_period = @history_retention_period
,@curdate_utc = @curdate_utc
if (@retcode != 0 or @@error != 0)
return 1
--
-- all done
--
return 0
end

sp_processlogshippingmonitorhistory (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_processlogshippingmonitorhistory(tinyint @mode
, uniqueidentifier @agent_id
, tinyint @agent_type
, int @session_id
, tinyint @session_status
, nvarchar @monitor_server
, bit @monitor_server_security_mode
, nvarchar @database
, datetime @log_time
, datetime @log_time_utc
, nvarchar @message)

MetaData:

 create procedure sys.sp_processlogshippingmonitorhistory   
(
@mode tinyint -- 1 = add, 2 = delete
,@agent_id uniqueidentifier
,@agent_type tinyint -- 0 = backup, 1 = copy, 2 = restore
,@session_id int = NULL
,@session_status tinyint = NULL -- 0 = Starting, 1 = Running, 2 = Success, 3 = Error, 4 = Warning
,@monitor_server sysname
,@monitor_server_security_mode bit
,@database sysname = NULL -- needed for add
,@log_time datetime = NULL
,@log_time_utc datetime = NULL
,@message nvarchar(4000) = NULL -- should this be nvarchar(4000) since linked server may not process (max)
)
as
begin
set nocount on
declare @retcode int

--
-- security check
--
exec @retcode = sys.sp_MSlogshippingsysadmincheck
if (@retcode != 0 or @@error != 0)
return 1
--
-- This should be called only on the remote monitor server
--
if (@monitor_server is null or upper(@monitor_server) != upper(@@servername))
return 0
--
-- must be invoked from MSDB
--
if (db_name() != N'msdb')
begin
raiserror (21482, 16, -1, N'sp_processlogshippingmonitorhistory', N'msdb')
return 1
end
--
-- call the internal proc now
--
exec @retcode = sys.sp_MSprocesslogshippingmonitorhistory
@mode = @mode
,@agent_id = @agent_id
,@agent_type = @agent_type
,@session_id = @session_id
,@session_status = @session_status
,@monitor_server = @monitor_server
,@monitor_server_security_mode = @monitor_server_security_mode
,@database = @database
,@log_time = @log_time
,@log_time_utc = @log_time_utc
,@message = @message
if (@retcode != 0 or @@error != 0)
return 1
--
-- all done
--
return 0
end

sp_password (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_password(nvarchar @old
, nvarchar @new
, nvarchar @loginame)

MetaData:

 create procedure sys.sp_password  
@old sysname = NULL, -- the old (current) password
@new sysname, -- the new password
@loginame sysname = NULL -- user to change password on
as
-- SETUP RUNTIME OPTIONS / DECLARE VARIABLES --
set nocount on
declare @exec_stmt nvarchar(4000)

-- RESOLVE LOGIN NAME
if @loginame is null
select @loginame = suser_sname()

if @new is null
select @new = ''

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

-- CHECK IT'S A SQL LOGIN --
if not exists (select * from master.dbo.syslogins where
loginname = @loginame and isntname = 0)
begin
raiserror(15007,-1,-1,@loginame)
return (1)
end

if @old is null
set @exec_stmt = 'alter login ' + quotename(@loginame) +
' with password = ' + quotename(@new, '''')
else
set @exec_stmt = 'alter login ' + quotename(@loginame) +
' with password = ' + quotename(@new, '''') + ' old_password = ' + quotename(@old, '''')

exec (@exec_stmt)

if @@error <> 0
return (1)

-- RETURN SUCCESS --
return (0) -- sp_password

sp_procedure_params_rowset2 (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_procedure_params_rowset2(nvarchar @procedure_schema
, nvarchar @parameter_name)

MetaData:

   
create procedure sys.sp_procedure_params_rowset2
(
@procedure_schema sysname = null,
@parameter_name sysname = null
)
as
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-- copy & pasted from version 1 of the SProc and removed checks for 1st parameter !
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
select
PROCEDURE_CATALOG = s_pp.PROCEDURE_CATALOG,
PROCEDURE_SCHEMA = s_pp.PROCEDURE_SCHEMA,
PROCEDURE_NAME = convert(nvarchar(134),
s_pp.PROCEDURE_NAME +';'+
ltrim(str(coalesce(s_pp.procedure_number,1), 5))),
PARAMETER_NAME = s_pp.PARAMETER_NAME,
ORDINAL_POSITION = s_pp.ORDINAL_POSITION,
PARAMETER_TYPE = s_pp.PARAMETER_TYPE,
PARAMETER_HASDEFAULT = s_pp.PARAMETER_HASDEFAULT,
PARAMETER_DEFAULT = s_pp.PARAMETER_DEFAULT,
IS_NULLABLE = s_pp.IS_NULLABLE,
DATA_TYPE = s_pp.DATA_TYPE_28, -- for backward compatibility
CHARACTER_MAXIMUM_LENGTH = s_pp.CHARACTER_MAXIMUM_LENGTH_28, -- for backward compatibility
CHARACTER_OCTET_LENGTH = s_pp.CHARACTER_OCTET_LENGTH_28, -- for backward compatibility
NUMERIC_PRECISION = s_pp.NUMERIC_PRECISION,
NUMERIC_SCALE = s_pp.NUMERIC_SCALE,
DESCRIPTION = s_pp.DESCRIPTION,
TYPE_NAME = s_pp.TYPE_NAME_28, -- for backward compatibility
LOCAL_TYPE_NAME = s_pp.LOCAL_TYPE_NAME_28 -- for backward compatibility

from
sys.spt_procedure_params_view s_pp

where
(@procedure_schema is null or schema_id(@procedure_schema) = s_pp.schema_id)
and
(
(s_pp.type in ('P', 'PC')) or
(s_pp.procedure_number = 0 and s_pp.type in ('FN', 'TF', 'IF'))
) and
(@parameter_name is null or @parameter_name = s_pp.PARAMETER_NAME)

UNION ALL

select
PROCEDURE_CATALOG = s_pprv.PROCEDURE_CATALOG,
PROCEDURE_SCHEMA = s_pprv.PROCEDURE_SCHEMA,
PROCEDURE_NAME = convert(nvarchar(134),
s_pprv.PROCEDURE_NAME +';'+
ltrim(str(coalesce(s_pprv.procedure_number,1), 5))),
PARAMETER_NAME = s_pprv.PARAMETER_NAME,
ORDINAL_POSITION = s_pprv.ORDINAL_POSITION,
PARAMETER_TYPE = s_pprv.PARAMETER_TYPE,
PARAMETER_HASDEFAULT = s_pprv.PARAMETER_HASDEFAULT,
PARAMETER_DEFAULT = s_pprv.PARAMETER_DEFAULT,
IS_NULLABLE = s_pprv.IS_NULLABLE,
DATA_TYPE = s_pprv.DATA_TYPE, -- Return value is either int or empty.
CHARACTER_MAXIMUM_LENGTH = s_pprv.CHARACTER_MAXIMUM_LENGTH,
CHARACTER_OCTET_LENGTH = s_pprv.CHARACTER_OCTET_LENGTH,
NUMERIC_PRECISION = s_pprv.NUMERIC_PRECISION,
NUMERIC_SCALE = s_pprv.NUMERIC_SCALE,
DESCRIPTION = s_pprv.DESCRIPTION,
TYPE_NAME = s_pprv.TYPE_NAME,
LOCAL_TYPE_NAME = s_pprv.LOCAL_TYPE_NAME

from
sys.spt_procedure_params_return_values_view s_pprv

where
(@procedure_schema is null or schema_id(@procedure_schema) = s_pprv.schema_id) and
(
@parameter_name is null or
(@parameter_name = '@RETURN_VALUE' and s_pprv.type in ('P', 'PC')) or
(@parameter_name = '@TABLE_RETURN_VALUE' and s_pprv.type <> 'P' and s_pprv.type <> 'PC')
)

order by 2, 3, 5

sp_MSvalidate_subscription (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_MSvalidate_subscription(nvarchar @subscriber
, nvarchar @subscriber_db
, int @artid)

MetaData:

 create procedure sys.sp_MSvalidate_subscription (  
@subscriber sysname,
@subscriber_db sysname,
@artid int
)
as
begin
if not exists (select *
from syssubscriptions as sub
where sub.srvname = UPPER(@subscriber)
and (sub.srvname is not null and len(sub.srvname)> 0)
and sub.artid = @artid
and sub.dest_db = @subscriber_db)
begin
-- The subscription has been dropped from the publisher. Please run sp_subscription_cleanup to cleanup the triggers.
exec sys.sp_MSreplraiserror 21161
return -1
end
end

sp_oledb_ro_usrname (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_oledb_ro_usrname()

MetaData:

   
create procedure sys.sp_oledb_ro_usrname
as
select
substring('NY',is_read_only+1,1),user_name()
from
sys.databases
where
name=DB_NAME()

sp_oledb_deflang (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_oledb_deflang()

MetaData:

   
create procedure sys.sp_oledb_deflang
as
if serverproperty('EngineEdition') = 5
begin
if db_name() <> N'master'
begin
raiserror(40634,-1,-1)
return
end

EXEC('
select
ISNULL(default_language_name,'
'us_english'')
from
sys.sql_logins
where
sid=SUSER_SID()'
)
end
else
begin
EXEC('
select
ISNULL(language,'
'us_english'')
from
master..syslogins
where
sid=SUSER_SID()'
)
end

Total Pageviews