Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_addserver

  No additional text.


Syntax
create procedure sys.sp_addserver
	@server			sysname,			-- server name
	@local			varchar(10) = NULL,	-- NULL or 'local'
	@duplicate_ok	varchar(13) = NULL	-- NULL or 'duplicate_ok'
as
	-- VARS
	DECLARE @localentry	bit,
			@dup_ok		bit,
			@retcode	int
	select @duplicate_ok = LOWER (@duplicate_ok collate Latin1_General_CI_AS)

	-- VALIDATE PARAMETERS/OPTIONS
	SELECT	@localentry = CASE WHEN @local IS NULL THEN 0
						WHEN lower(@local) = 'local' THEN 1
						ELSE NULL END,
			@dup_ok = CASE WHEN @duplicate_ok IS NULL THEN 0
						WHEN @duplicate_ok = 'duplicate_ok' THEN 1
						ELSE NULL END
	IF @localentry IS NULL OR @dup_ok IS NULL
	BEGIN
		raiserror(15600,-1,-1,'sys.sp_addserver')
		return (1)
	END

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

	BEGIN TRANSACTION

	-- ADD THE SERVER (CHECKS PERMISSIONS, ETC)
	EXEC @retcode = sys.sp_MSaddserver_internal @server,
				NULL, NULL, NULL, NULL, NULL, NULL, -- @srvproduct ... @catalog
				0,			-- @linkedstyle
				@localentry

	if( @retcode = 0)
	begin
		if (@localentry = 1)
		begin
			-- EMDEventType(x_eet_Alter_Instance), EMDUniversalClass(x_eunc_Server), 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 = 214, ID = 100, ID = 0, ID = 0, Value = NULL,
				ID = -1, ID = 0, ID = 0, Value = NULL,
				ID = 3, Value = @server, Value = @local, Value = @duplicate_ok, Value = NULL, Value = NULL, Value = NULL, Value = NULL)
		end
		else
		begin
			-- EMDEventType(x_eet_Create_Remote_Server), EMDUniversalClass(x_eunc_Server), 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 = 230, ID = 100, ID = 0, ID = 0, Value = @server,
				ID = -1, ID = 0, ID = 0, Value = NULL,
				ID = 3, Value = @server, Value = @local, Value = @duplicate_ok, Value = NULL, Value = NULL, Value = NULL, Value = NULL)
		end

		COMMIT TRANSACTION
		-- SUCCESS
		return (0) -- sp_addserver
	end
	else if( @retcode = 2 )
	begin
		ROLLBACK

		if @dup_ok = 1
			return (0)
		else
			begin
				raiserror(15028,-1,-1,@server);
				return (1);
			end;
	end
	else
	begin
		ROLLBACK
		return (1)
	end

 
Last revision 2008RTM
See also

  sp_adddistributor (Procedure)
sp_MSaddserver_internal (Procedure)
sp_MSadd_subscriber_info (Procedure)
sp_MSadd_subscriber_schedule (Procedure)
sp_MSadd_subserver (Procedure)
sp_MSrepl_adddistpublisher (Procedure)
sp_MSrepl_testadminconnection (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