April 22, 2012

sp_dsninfo (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_dsninfo(varchar @dsn
, varchar @infotype
, varchar @login
, varchar @password
, int @dso_type)

MetaData:

   
--
-- Name: sp_dsninfo
--
-- Descriptions:
--
-- Parameters: as defined in create statement
--
-- Returns: 0 - success
-- 1 - Otherwise
--
-- Security:
-- Requires Certificate signature for catalog access
--
create procedure sys.sp_dsninfo
-- xp_dsninfo does not support unicode
@dsn varchar(128),
@infotype varchar(128) = NULL,
@login varchar(128) = NULL,
@password varchar(128) = NULL,
@dso_type int = 1 -- 1 is ODBC, 3 OLEDB. --
AS

SET NOCOUNT ON

DECLARE @distributor sysname
DECLARE @distproc nvarchar (300)
DECLARE @retcode int
DECLARE @dsotype_odbc int
DECLARE @dsotype_oledb int

select @dsotype_odbc = 1
select @dsotype_oledb = 3

--
-- Security Check: require sysadmin
--
IF (ISNULL(IS_SRVROLEMEMBER('sysadmin'),0) = 0)
BEGIN
RAISERROR(21089,16,-1)
RETURN (1)
END

--
-- Get distribution server information for remote RPC
-- subscription calls.
--

EXEC @retcode = sys.sp_MSrepl_getdistributorinfo @rpcsrvname = @distributor OUTPUT
IF @@error <> 0 OR @retcode <> 0
BEGIN
RAISERROR (14071, 16, -1)
RETURN (1)
END

if (@dso_type = @dsotype_odbc)
begin
--
-- Call xp_dsninfo
--
SELECT @distproc = QUOTENAME(RTRIM(@distributor)) + '.master.dbo.xp_dsninfo'
EXEC @retcode = @distproc @dsn, @infotype, @login, @password
IF @@error <> 0
BEGIN
RAISERROR (14071, 16, -1)
RETURN (1)
END
end
else if (@dso_type = @dsotype_oledb)
begin
--
-- Call sp_oledbinfo
--
EXEC @retcode = sys.sp_oledbinfo @dsn, @infotype, @login, @password
IF @@error <> 0
BEGIN
RAISERROR (14071, 16, -1)
RETURN (1)
END
end

No comments:

Post a Comment

Total Pageviews