Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSchangerepllinkedsrvrpassword

  No additional text.


Syntax
CREATE PROCEDURE sys.sp_MSchangerepllinkedsrvrpassword
(
	@server 		sysname,
	@remote_login	sysname,
	@new_password	nvarchar(524),
	@server_type	sysname = N'MSSQLSERVER'
)
AS
BEGIN
	SET NOCOUNT ON
	
	DECLARE @retcode		int
	DECLARE @server_name	sysname
	DECLARE @local_login	sysname

	-- only test the connection for hetero
	IF @server_type != N'MSSQLSERVER'
	BEGIN
		EXEC @retcode = sys.sp_MSrepl_testconnection
						@publisher_type = @server_type,
						@publisher		= @server,
						@security_mode	= 0,
						@login			= @remote_login,
						@password		= @new_password

		IF @@ERROR<>0 OR @retcode<>0
		BEGIN
			RAISERROR(21673, 16, -1, @server)
			RETURN (1)
		END
	END
	
	-- Update linked server login mappings
	CREATE TABLE #logins
	(
		server			sysname,
		login			sysname null,
		is_self 		bit,
		remote_login	sysname null
	)

	-- Get linked server logins
	IF @server = N'%'
	BEGIN
		insert into #logins
			exec sys.sp_helplinkedsrvlogin
	END
	ELSE
	BEGIN
		insert into #logins
			exec sys.sp_helplinkedsrvlogin @rmtsrvname = @server
	END

	DECLARE hLogins CURSOR FORWARD_ONLY FOR
	SELECT	server,
			login
	FROM	#logins
	WHERE	remote_login	= @remote_login
	and 	is_self 		= 0

	OPEN hLogins
	FETCH NEXT FROM hLogins INTO @server_name, @local_login
	WHILE (@@fetch_status = 0)
	BEGIN
		-- update linked server login mapping with new password
		EXEC @retcode = sys.sp_addlinkedsrvlogin	@rmtsrvname 	= @server_name,
													@useself		= 'false',
													@locallogin 	= @local_login,
													@rmtuser		= @remote_login,
													@rmtpassword	= @new_password

		IF @@error <> 0 OR @retcode <> 0
		BEGIN
			RAISERROR(21674, 10, -1, @server_name, @local_login)
			CONTINUE
		END

		RAISERROR(21451, 10, -1, 'linked', 'server', @server_name, @remote_login) WITH LOG
		
		-- Get next login
		FETCH NEXT FROM hLogins INTO @server_name, @local_login
	END

	CLOSE hLogins
	DEALLOCATE hLogins
	DROP TABLE #logins

	RETURN 0
END

 
Last revision 2008RTM
See also

  sp_changedistpublisher (Procedure)
sp_changereplicationserverpasswords (Procedure)
sp_MSchangepublicationlinkpasswords (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