|
|
|
SSCertifiable
       
Group: Moderators
Last Login: Tuesday, June 11, 2013 6:34 AM
Points: 6,463,
Visits: 1,388
|
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 10:45 AM
Points: 10,613,
Visits: 11,957
|
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, September 27, 2010 8:38 AM
Points: 236,
Visits: 99
|
|
Not sure how this procedure, sp_scriptdynamicupdateproc , is used, it won't parse for me. Can you give an example of it beign called please?
"There is one other option for updates, but you won't find it in the UI. You can run sp_scriptdynamicupdateproc to generate a stored procedure that will build and execute dynamic SQL on the subscriber. Running the procedure just generates the script, it is up to you to apply it to all of your subscribers. The tradeoff when using this is that you only touch truly changed columns which may increase performance if many of the columns are indexed, in return you incur the overhead of building the statement and executing it each time. Here's what we what we would get from our original test table after running the proc on the publisher"
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, September 27, 2010 8:38 AM
Points: 236,
Visits: 99
|
|
Not sure how this procedure, sp_scriptdynamicupdateproc , is used, it won't parse for me. Can you give an example of it beign called please?
"There is one other option for updates, but you won't find it in the UI. You can run sp_scriptdynamicupdateproc to generate a stored procedure that will build and execute dynamic SQL on the subscriber. Running the procedure just generates the script, it is up to you to apply it to all of your subscribers. The tradeoff when using this is that you only touch truly changed columns which may increase performance if many of the columns are indexed, in return you incur the overhead of building the statement and executing it each time. Here's what we what we would get from our original test table after running the proc on the publisher"
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, September 27, 2010 8:38 AM
Points: 236,
Visits: 99
|
|
Not sure how this procedure, sp_scriptdynamicupdateproc , is used, it won't parse for me. Can you give an example of it beign called please?
"There is one other option for updates, but you won't find it in the UI. You can run sp_scriptdynamicupdateproc to generate a stored procedure that will build and execute dynamic SQL on the subscriber. Running the procedure just generates the script, it is up to you to apply it to all of your subscribers. The tradeoff when using this is that you only touch truly changed columns which may increase performance if many of the columns are indexed, in return you incur the overhead of building the statement and executing it each time. Here's what we what we would get from our original test table after running the proc on the publisher"
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Thursday, January 13, 2011 2:58 PM
Points: 64,
Visits: 70
|
|
Hi Andy,
Great Article. Very thorough and informative.
When I create a publication, I use the default settings (CALL for INSERT and DELETE and SCALL for UPDATE), and as expected I get these 3 procedures, as described in your article:
[sp_MSdel_dboTableName] [sp_MSins_dboTableName] [sp_MSupd_dboTableName]
However, in addition, unexpectedly I get two more procedures:
[sp_MSdel_dboTableName_msrepl_ccs] [sp_MSins_dboTableName_msrepl_ccs]
Basically, it's just an extra insert and an extra delete procedure with msrepl_ccs appended to the end of the names.
The difference in the delete procedure is that it does not post the error if the rowcount is 0. The difference in the insert procedure is that it checks to see if a record exists with the same pk, and if one does, it will update that record (instead of doing an insert that would ultimately fail).
I don't believe these procedures are being called by anything. It seems as though they are just there. The only reason I can think of is that if someone wants that type of behavior, they can simply change the properties of the article to call those procs instead of the other ones.
I haven't seen any documentation on it, and you didn't mention it in your article.
Do you have any explanation for why these procedures are being created? Do you know of any way to prevent them from being created? (if they are not being used, then they are just cluttering up the list of stored procedures).
|
|
|
|
|
SSCertifiable
       
Group: Moderators
Last Login: Tuesday, June 11, 2013 6:34 AM
Points: 6,463,
Visits: 1,388
|
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Thursday, January 13, 2011 2:58 PM
Points: 64,
Visits: 70
|
|
SQL Server 2005. Transactional (standard). Distribution Server set up on another machine.
As straight forward a publication as you could imagine. Single table, no row filters, no column filters. I'm fairly new to replication, and in doing all of the set up through the wizards, I haven't deviated from the default settings at all.
Every time I subscribe to a publication, these 2 extra sps get created.
One of my collegues noticed that when you set distribution to run locally, these 2 sps are not created... I wonder what that has to do with it...
Andy, do you not get these when sp's when you set up trans rep in 2005?
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Thursday, January 13, 2011 2:58 PM
Points: 64,
Visits: 70
|
|
And here they are... the 5 sp's that I get for this table:
CREATE TABLE [dbo].[test_for_replication]( [id] [int] NOT NULL PRIMARY KEY, [name] [varchar](30) NOT NULL, [description] [varchar](255) NOT NULL)
The ones being used are:
sp_MSdel_dbotest_for_replication sp_MSins_dbotest_for_replication sp_MSupd_dbotest_for_replication
The seemingly superfluous ones are:
sp_MSdel_dbotest_for_replication_msrepl_ccs sp_MSins_dbotest_for_replication_msrepl_ccs
Here are the create proc scripts for all of them:
CREATE procedure [dbo].[sp_MSdel_dbotest_for_replication] @pkc1 int as begin delete "dbo"."test_for_replication" where "id" = @pkc1 if @@rowcount = 0 if @@microsoftversion>0x07320000 exec sp_MSreplraiserror 20598 end
create procedure [dbo].[sp_MSdel_dbotest_for_replication_msrepl_ccs] @pkc1 int as begin delete "dbo"."test_for_replication" where "id" = @pkc1 end
create procedure [dbo].[sp_MSins_dbotest_for_replication] @c1 int,@c2 varchar(30),@c3 varchar(255) as begin insert into "dbo"."test_for_replication"( "id" ,"name" ,"description" ) values ( @c1 ,@c2 ,@c3 ) end
create procedure [dbo].[sp_MSins_dbotest_for_replication_msrepl_ccs] @c1 int,@c2 varchar(30),@c3 varchar(255) as begin if exists ( select * from "dbo"."test_for_replication" where "id" = @c1 ) begin update "dbo"."test_for_replication" set "name" = @c2 ,"description" = @c3 where "id" = @c1 end else begin insert into "dbo"."test_for_replication"( "id" ,"name" ,"description" ) values ( @c1 ,@c2 ,@c3 ) end end
create procedure [dbo].[sp_MSupd_dbotest_for_replication] @c1 int = null,@c2 varchar(30) = null,@c3 varchar(255) = null,@pkc1 int ,@bitmap binary(1) as begin if ( substring(@bitmap,1,1) & 1 = 1 ) begin update "dbo"."test_for_replication" set "id" = case substring(@bitmap,1,1) & 1 when 1 then @c1 else "id" end ,"name" = case substring(@bitmap,1,1) & 2 when 2 then @c2 else "name" end ,"description" = case substring(@bitmap,1,1) & 4 when 4 then @c3 else "description" end where "id" = @pkc1 if @@rowcount = 0 if @@microsoftversion>0x07320000 exec sp_MSreplraiserror 20598 end else begin update "dbo"."test_for_replication" set "name" = case substring(@bitmap,1,1) & 2 when 2 then @c2 else "name" end ,"description" = case substring(@bitmap,1,1) & 4 when 4 then @c3 else "description" end where "id" = @pkc1 if @@rowcount = 0 if @@microsoftversion>0x07320000 exec sp_MSreplraiserror 20598 end end
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Wednesday, January 30, 2013 12:29 PM
Points: 98,
Visits: 227
|
|
Hi msuarez
I am also seeing similarly named stored procedures being created when I apply a snapshot after configuring transactional replication. They also appear when adding articles to an existing publication.
The important point is, though, that they (should) disappear immediately after the snapshot has been applied. they seem to be temporary in nature, for whatever purpose.
Cheers
Simon
|
|
|
|