Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSrepl_changepublication_snapshot

  No additional text.


Syntax
create procedure sys.sp_MSrepl_changepublication_snapshot
(
    @publication					sysname,
    @frequency_type					int,
    @frequency_interval				int,
    @frequency_subday				int,
    @frequency_subday_interval		int,
    @frequency_relative_interval	int,
    @frequency_recurrence_factor	int,
    @active_start_date				int,
    @active_end_date				int,
    @active_start_time_of_day		int,
    @active_end_time_of_day			int,
    @snapshot_job_name				nvarchar(100),
	@publisher_security_mode		int,
	@publisher_login				sysname,
	@publisher_password 			sysname,
	@job_login 						nvarchar(257),
	@job_password 					sysname,
	@publisher						sysname,
	@publisher_type					sysname
)
AS
BEGIN
    SET NOCOUNT ON

    DECLARE @retcode			int,
    		@distproc			nvarchar(1000),
    		@distributor_rpc	sysname,
    		@distribution_db	sysname,
    		@publisher_db		sysname,
    		@snapagent_exists 	bit,
			@proxy_id			int

	-- Security Check
    EXEC @retcode = sys.sp_MSreplcheck_publish
    IF @@ERROR <> 0 OR @retcode <> 0
		RETURN 1

	-- Parameter Check
    EXEC @retcode = sys.sp_MSreplcheck_name @publication, '@publication', 'sp_MSrepl_changepublication_snapshot'
    IF @@ERROR <> 0 OR @retcode <> 0
		RETURN 1

	SELECT @publisher 		= ISNULL(@publisher, publishingservername()),
			@publisher_db	= db_name()
	
    -- ensure that we are published and then go to work
	IF sys.fn_MSrepl_ispublished(@publisher_db) != 1
	BEGIN
		-- The database is not published.
		RAISERROR (18757, 16, -1)
		RETURN 1
	END
	
	IF @publisher_type = N'MSSQLSERVER'
	BEGIN
		-- check security mode
		IF @publisher_security_mode IS NOT NULL
		BEGIN
			IF @publisher_security_mode not in (0, 1)
			BEGIN
				-- The specified '@publisher_security_mode' is invalid (valid values are: 0, 1).
				RAISERROR(14266, 16, -1, '@publisher_security_mode', '0, 1')
				RETURN 1
			END

			-- make sure that the login is valid
			SELECT @publisher_login = RTRIM(LTRIM(ISNULL(@publisher_login, '')))
			IF @publisher_security_mode = 0 AND @publisher_login = ''
			BEGIN
				-- '@publisher_login cannot be null or empty when @publisher_security_mode is set to 0 (SQL Server authentication).'
				RAISERROR(21694, 16, -1, '@publisher_login', '@publisher_security_mode')
				RETURN 1
			END
		END
		
		-- if the snapshot login was supplied it must be valid
		IF @job_login IS NOT NULL
		BEGIN
			IF sys.fn_replisvalidwindowsloginformat(@job_login) != 1
			BEGIN
				-- '@job_login' must be a valid Windows Login in the form : 'MACHINE\Login' or 'DOMAIN\Login'. Please see the documentation for 'sp_changepublication_snapshot'.
				RAISERROR(21797, 16, -1, '@job_login', 'sp_changepublication_snapshot')
				RETURN 1
			END
		END
	END
	-- HETERO
	ELSE
	BEGIN
		IF @publisher_security_mode IS NOT NULL
		BEGIN
			-- The @publisher_security_mode parameter value can not be updated/changed for heterogeneous publications.
			RAISERROR(22536, 16, -1, '@publisher_security_mode')
			RETURN 1
		END

		IF @publisher_login IS NOT NULL
		BEGIN
			-- The @publisher_login parameter value can not be updated/changed for heterogeneous publications.
			RAISERROR(22536, 16, -1, '@publisher_login')
			RETURN 1
		END

		IF @publisher_password IS NOT NULL
		BEGIN
			-- The @publisher_password parameter value can not be updated/changed for heterogeneous publications.
			RAISERROR(22536, 16, -1, '@publisher_password')
			RETURN 1
		END

		/*
		** In this case we will allow @job_login to be changed only if the
		** publisher_security_mode was set to 0 when the distpublisher was
		** configured. Error is raised in sp_MSchange_snapshot_agent_properties.
		*/
		-- IF @job_login IS NOT NULL
		-- BEGIN
		-- 	-- The @job_login parameter value can not be updated/changed for heterogeneous publications.
		-- 	RAISERROR(22536, 16, -1, '@job_login')
		-- 	RETURN 1
		-- END
	END
	
	-- retrieve the distributor db information
    EXEC @retcode = sys.sp_helpdistributor @rpcsrvname = @distributor_rpc OUTPUT,
    										@distribdb = @distribution_db OUTPUT,
    										@publisher = @publisher
	IF @@ERROR <> 0 OR @retcode <> 0 OR @distribution_db is NULL
	BEGIN
		-- "The Distributor has not been installed correctly."
		RAISERROR (20036, 16, -1)
		RETURN 1
	END

	SELECT @distproc = QUOTENAME(@distributor_rpc) + '.' + QUOTENAME(@distribution_db) + '.sys.sp_MSreplagentjobexists'
	EXEC @retcode =  @distproc @type = 3,
								@exists = @snapagent_exists OUTPUT,
								@proxy_id = @proxy_id OUTPUT,
								@publisher = @publisher,
								@publisher_db = @publisher_db,
								@publication = @publication
	IF @retcode <> 0 OR @@ERROR <> 0
		RETURN 1

	-- EXIT if NOT FOUND
	IF @snapagent_exists = 0
	BEGIN	
		-- "The snapshot agent for publisher (%s), database (%s), publication (%s) could not be found."
		RAISERROR(21799, 16, -1, 'snapshot', @publisher, @publisher_db, @publication)
		RETURN 1
	END

	IF IS_SRVROLEMEMBER('sysadmin') != 1
		AND @proxy_id IS NULL
	BEGIN
		-- Only members of the sysadmin fixed server role can modify a snapshot agent that does not have a job with a proxy account defined.
		RAISERROR(20813, 16, -1, 'snapshot agent')
		RETURN 1
	END	
	
	SELECT @distproc = QUOTENAME(@distributor_rpc) + '.' + QUOTENAME(@distribution_db) + '.sys.sp_MSchange_snapshot_agent_properties'
  	EXEC @retcode = @distproc @publisher						= @publisher,
								@publisher_db					= @publisher_db,
								@publication					= @publication,
								@frequency_type					= @frequency_type,
							    @frequency_interval				= @frequency_interval,
							    @frequency_subday				= @frequency_subday,
							    @frequency_subday_interval		= @frequency_subday_interval,
							    @frequency_relative_interval	= @frequency_relative_interval,
							    @frequency_recurrence_factor	= @frequency_recurrence_factor,
							    @active_start_date				= @active_start_date,
							    @active_end_date				= @active_end_date,
							    @active_start_time_of_day		= @active_start_time_of_day,
							    @active_end_time_of_day			= @active_end_time_of_day,
							    @snapshot_job_name				= @snapshot_job_name,
								@publisher_security_mode		= @publisher_security_mode,
								@publisher_login				= @publisher_login,
								@publisher_password 			= @publisher_password,
								@job_login						= @job_login,
								@job_password					= @job_password,
								@publisher_type					= @publisher_type
				
    IF @retcode <> 0 OR @@ERROR <> 0
        RETURN 1
	
	RETURN 0
END

 
Last revision 2008RTM
See also

  sp_changepublication_snapshot (Procedure)
sp_MSdrop_replcom (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