Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSaddserver_internal

  No additional text.


Syntax

-- NOTE: FOR INTERNAL USE ONLY!
--	  DO NOT DOCUMENT OR USE!

create procedure sys.sp_MSaddserver_internal
	@server			sysname,			-- server name
	@srvproduct		nvarchar(128),		-- product name
	@provider		nvarchar(128),		-- oledb provider name
	@datasrc		nvarchar(4000),		-- oledb datasource property
	@location		nvarchar(4000),		-- oledb location property
	@provstr		nvarchar(4000),		-- oledb provider-string property
	@catalog		sysname,			-- oledb catalog property
	@linkedstyle	bit,				-- if =0 use sp_addserver semantics
	@localentry		bit					-- use id=0 if =1
as
	-- VARIABLES
	declare @retcode	int,
			@srvid		int,
			@dataaccess	bit,
			@dtcpromotionforremoteproc bit,
			@rpcin		bit,
			@rpcout		bit


	-- CHECK PERMISSIONS
	if not (has_perms_by_name(null, null, 'alter any linked server') = 1)
	begin
		EXEC %%System().AuditEvent(ID = 1380143948, Success = 0, TargetLoginName = NULL, TargetUserName = NULL, Role = NULL, Object = NULL, Provider = @provider, Server = @server)
		raiserror(15247,-1,-1)
		return (1) -- non-dup error
	end
	else
	begin
		EXEC %%System().AuditEvent(ID = 1380143948, Success = 1, TargetLoginName = NULL, TargetUserName = NULL, Role = NULL, Object = NULL, Provider = @provider, Server = @server)
	end

	-- VALIDATE SERVER NAME
	EXEC @retcode = sys.sp_validname @server
	if @retcode <> 0
		return (1) -- non-dup error

	-- SET GENERAL DEFAULTS
	SELECT	@dataaccess = @linkedstyle,		-- Linked-servers get data access
			@dtcpromotionforremoteproc = @linkedstyle,	-- Linked-servers get DtcPromotionForRemoteProc
			@rpcin = 0, @rpcout = 0			-- No RPC for non-SQL Server

	-- HANDLE DEFAULTS FOR SQL Server PROVIDER
	if @provider is null
	begin
		select	@srvproduct = N'SQL Server',		-- force case to be this
				@provider = N'SQLNCLI',				-- SQL Server provider (SNAC)
				@datasrc = @server,					-- datasrc is (network) server name
				@location = NULL,
				@provstr = NULL,
				@catalog = NULL,
				@rpcin = 1, @rpcout = 1				-- enable RPC for SQL Server
	end

	-- CREATE INITIAL LOGIN -- Raises xact-abort error if row-too-long
	EXEC %%LinkedServer () . NewServer (
				Name = @server,
 				Product = @srvproduct,
				Provider = @provider,
				Local = @localentry,
				Linked = @linkedstyle,
				RPCIn = @rpcin,
				RPCOut = @rpcout,
				DataAccess = @dataaccess,
				DtcPromotionForRemoteProc = @dtcpromotionforremoteproc,
				Datasource = @datasrc,
				Location = @location,
				ProviderString = @provstr,
				Catalog = @catalog)

	-- CHECK FOR DUPLICATE
	IF @@ERROR <> 0
	BEGIN
		return (2); -- dup
	END

	EXEC %%LinkedServer(Name=@server).SetUseRemoteCollation(Value=1)	-- Other props correctly default to 0/NULL

	-- ADD DEFAULT MAPPING FOR OUTGOING EVENTS
	EXEC %%LinkedServer(Name=@server).NewLinkedLogin(LocalID=0, UseSelf=1, RemoteName=NULL, Password=NULL)

	-- SUCCESS
	return (0) -- sp_MSaddserver_internal

 
Last revision 2008RTM
See also

  sp_addlinkedserver (Procedure)
sp_addserver (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash