sql server replication:
I think Im missing a big part of sometihng here in regards to Custom Sync Object. (Subscriber has more columns than Publisher) I can make this work without a Custom Sync Object. It will work if I use a nosync approach, therefore not needing to BCP the snapshot to the Subscriber. Please read on after these schemas and procs. Heres my current schemas. --Publisher table CREATE TABLE [dbo].[TransDtl] ( [TransDtlKey] [int] IDENTITY (1, 1) NOT NULL , [CustomerKey] [int] NULL , [SerialNbr] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [TranCode] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [TransDate] [smalldatetime] NOT NULL , [TransAmt] [money] NOT NULL , [RefNbr] [char] (23) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [MerchName] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [City] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [State] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [RejectReason] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [PostDate] [datetime] NOT NULL , [CreateDate] [datetime] NOT NULL , [MerchSIC] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY] GO --Sub table CREATE TABLE [dbo].[TransDtl] ( [TransDtlKey] [int] NOT NULL , [CustomerKey] [int] NULL , [SerialNbr] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [TranCode] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [TransDate] [smalldatetime] NULL , [TransDateShort] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [TransDateMonth] [tinyint] NULL , [TransDateYear] [smallint] NULL , [TransAmt] [money] NULL , [RefNbr] [char] (23) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [MerchName] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [City] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [State] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [RejectReason] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [PostDate] [datetime] NULL , [PostDateShort] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [PostDateMonth] [tinyint] NULL , [PostDateYear] [smallint] NULL , [CreateDate] [datetime] NULL , [MerchSIC] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY] GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO --Insert proc ALTER procedure sp_msIns_TransDtl @TransDtlKey int , @CustomerKey int , @SerialNbr char (10) , @TranCode char (4) , @TransDate smalldatetime , @TransAmt money , @RefNbr char (23) , @MerchName varchar (25) , @City varchar (15) , @State varchar (3) , @RejectReason varchar (15) , @PostDate datetime , @CreateDate datetime , @MerchSIC char (4) as insert into TransDTL ( TransDtlKey , CustomerKey , SerialNbr , TranCode , TransDate , TransDateShort , TransDateMonth , TransDateYear , TransAmt , RefNbr , MerchName , City , State , RejectReason , PostDate , PostDateShort , PostDateMonth , PostDateYear , CreateDate , MerchSIC ) values ( @TransDtlKey , @CustomerKey , @SerialNbr , @TranCode , @TransDate , Convert(varchar(10), @TransDate, 101), Month(@TransDate) , Year(@TransDate), @TransAmt , @RefNbr , @MerchName , @City , @State , @RejectReason , @PostDate , Convert(varchar(10), @PostDate, 101) , Month(@PostDate), Year(@PostDate) , @CreateDate , @MerchSIC ) GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO As mentioned, the above works for individual inserts. Of course not for the initial snapshot. Which is what I thought a Custom Sync Object could handle. I had also hoped that with a Custom Sync Object and telling the article to use it(below), I would be able to BCP the data for the Snapshot. But that blows up with an EOF. I think Im missing something big here??? create view SyncTransDTL as select TransDtlKey , CustomerKey , SerialNbr , TranCode , TransDate , TransDateShort = Convert(varchar(10), TransDate, 101), TransDateMonth = Month(TransDate), TransDateYear = Year(TransDate), TransAmt , RefNbr , MerchName , City , State , RejectReason , PostDate , PostDateShort = Convert(varchar(10), PostDate, 101), PostDateMonth = Month(PostDate), PostDateYear = Year(PostDate), CreateDate , MerchSIC from dbo.transdtl sp_addarticle @publication = 'transdtl' , @article = 'transdtl' , @source_table = 'transdtl' , @destination_table = 'transdtl' , @type = 'logbased manualview' , @sync_object = 'SyncTransDTL' , @creation_script = '\\location\d$\Replication\CreateTransDTL.txt' ,@ins_cmd = 'CALL sp_MSins_TransDTL' ,@del_cmd = 'CALL sp_MSdel_TransDTL' ,@upd_cmd = 'MCALL sp_MSupd_TransDTL' ,@schema_option = 0x00 ,@status = 8
--Subscriber/ Distributor Microsoft SQL Server 2000 - 8.00.818 (Intel X86) May 31 2003 16:08:15 Copyright (c) 1988-2003 Microsoft Corporation Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4) --Publisher Exactly the same [quoted text, click to view] >-----Original Message----- >This works for me. Can you do a select @@version on your SQL Server and post >it back here? > >create database ChrisR >go >create database ChrisRSub >go >use ChrisR >go > >CREATE TABLE TransDtl >( >TransDtlKey int IDENTITY(1, 1) NOT NULL PRIMARY KEY, >CustomerKey int NULL, >SerialNbr char(10), >TranCode char(4), >TransDate smalldatetime NOT NULL, >TransAmt money NOT NULL, >RefNbr char(23), >MerchName varchar(25), >City varchar(15), >State varchar(3), >RejectReason varchar(15), >PostDate datetime NOT NULL, >CreateDate datetime NOT NULL, >MerchSIC char(4) >) >GO >use chrisr >GO >Create View CustomSyncObject >as >select TransDtlKey=convert(int,TransDtlKey), >CustomerKey=convert(int,CustomerKey), >SerialNbr=convert(char(10),SerialNbr), >TranCode=convert(char(4),TranCode), >TransDate=convert(smalldatetime,TransDate), >TransDateShort = Convert(varchar(10),TransDate, 101), >TransDateMonth = convert(tinyint,Month(TransDate)), >TransDateYear = convert(smallint,Year(TransDate)), >TransAmt=convert(money, TransAmt), >RefNbr, MerchName, City, State, RejectReason, PostDate, >PostDateShort = Convert(varchar(10), PostDate, 101), >PostDateMonth = convert(tinyint, Month(PostDate)), >PostDateYear=convert(smallint, Year(PostDate)), >CreateDate, >MerchSIC from TransDtl >GO > >sp_dboption 'ChrisR','published','true' >go >sp_addpublication 'ChrisR',@status='active', @sync_method = N'character' >go >sp_addpublication_snapshot 'ChrisR' >go >sp_addarticle @publication = 'ChrisR', >@article = 'TransDTL', >@source_object = 'TransDTL', >@destination_table = 'TransDTL', >@type = 'logbased manualview', >@sync_object='CustomSyncObject', >@creation_script = 'c:\temp\TransDTL.sql', >@pre_creation_cmd = 'delete', >@schema_option = 0x0, >@status = 8, >@ins_cmd = 'CALL sp_MSins_TransDTL', >@del_cmd = 'CALL sp_MSdel_TransDTL', >@upd_cmd = 'MCALL sp_MSupd_TransDTL' >GO >use chrisRsub >go >if exists (select * from sysobjects where type = 'P' and name = >'sp_MSins_TransDTL') drop proc [sp_MSins_TransDTL] >go >create procedure [sp_MSins_TransDTL] @c1 int,@c2 int,@c3 char(10),@c4 >char(4),@c5 smalldatetime,@c6 money,@c7 char(23),@c8 varchar(25),@c9 >varchar(15),@c10 varchar(3),@c11 varchar(15),@c12 datetime,@c13 >datetime,@c14 char(4) > >AS >BEGIN > >insert into [TransDTL]( >[TransDtlKey], [CustomerKey], [SerialNbr], [TranCode], >[TransDate],[TransDateShort], >[TransDateMonth], [TransDateYear], [TransAmt], [RefNbr], [MerchName], >[City], [State], >[RejectReason], [PostDate],[PostDateShort], [PostDateMonth],[PostDateYear], >[CreateDate], [MerchSIC] > ) > >values ( >@c1, @c2, @c3, @c4, @c5, Convert(varchar(10), @c5, 101), Month(@c5), >Year(@c5), > @c6, @c7, @c8, @c9, @c10, @c11, @c12, Convert(varchar (10), @c12, 101), >Month(@c12), Year(@c12), @c13, @c14 > ) > >END >go > >if exists (select * from sysobjects where type = 'P' and name = >'sp_MSupd_TransDTL') drop proc [sp_MSupd_TransDTL] >go >create procedure [sp_MSupd_TransDTL] > @c1 int,@c2 int,@c3 char(10),@c4 char(4),@c5 smalldatetime,@c6 money,@c7 >char(23),@c8 varchar(25),@c9 varchar(15),@c10 varchar (3),@c11 >varchar(15),@c12 datetime,@c13 datetime,@c14 char (4),@pkc1 int >,@bitmap binary(2) >as >if substring(@bitmap,1,1) & 1 = 1 >begin >update [TransDTL] set >[TransDtlKey] = case substring(@bitmap,1,1) & 1 when 1 then @c1 else >[TransDtlKey] end >,[CustomerKey] = case substring(@bitmap,1,1) & 2 when 2 then @c2 else >[CustomerKey] end >,[SerialNbr] = case substring(@bitmap,1,1) & 4 when 4 then @c3 else >[SerialNbr] end >,[TranCode] = case substring(@bitmap,1,1) & 8 when 8 then @c4 else >[TranCode] end >,[TransDate] = case substring(@bitmap,1,1) & 16 when 16 then @c5 else >[TransDate] end >,[TransDateShort]= case substring(@bitmap,1,1) & 16 when 16 then >Convert(varchar(10), @c5, 101) else [TransDateShort] end >,[TransDateMonth]= case substring(@bitmap,1,1) & 16 when 16 then Month(@c5) >else [TransDateMonth] end >,[TransDateYear]= case substring(@bitmap,1,1) & 16 when 16 then Year(@c5) >else [TransDateYear] end >,[TransAmt] = case substring(@bitmap,1,1) & 32 when 32 then @c6 else >[TransAmt] end >,[RefNbr] = case substring(@bitmap,1,1) & 64 when 64 then @c7 else [RefNbr] >end >,[MerchName] = case substring(@bitmap,1,1) & 128 when 128 then @c8 else >[MerchName] end >,[City] = case substring(@bitmap,2,1) & 1 when 1 then @c9 else [City] end >,[State] = case substring(@bitmap,2,1) & 2 when 2 then @c10 else [State] end >,[RejectReason] = case substring(@bitmap,2,1) & 4 when 4 then @c11 else >[RejectReason] end >,[PostDate] = case substring(@bitmap,2,1) & 8 when 8 then @c12 else >[PostDate] end >,[PostDateShort] = case substring(@bitmap,2,1) & 8 when 8 then >Convert(varchar(10), @c12, 101) else [PostDateShort] end >,[PostDateMonth] = case substring(@bitmap,2,1) & 8 when 8 then Month(@c12) >else [PostDateMonth] end >,[PostDateYear] = case substring(@bitmap,2,1) & 8 when 8 then Year(@c12) >else [PostDateYear] end >,[CreateDate] = case substring(@bitmap,2,1) & 16 when 16 then @c13 else >[CreateDate] end >,[MerchSIC] = case substring(@bitmap,2,1) & 32 when 32 then @c14 else >[MerchSIC] end >where [TransDtlKey] = @pkc1 >if @@rowcount = 0 > if @@microsoftversion>0x07320000 > exec sp_MSreplraiserror 20598 >end >else >begin >update [TransDTL] set >[CustomerKey] = case substring(@bitmap,1,1) & 2 when 2 then @c2 else >[CustomerKey] end >,[SerialNbr] = case substring(@bitmap,1,1) & 4 when 4 then @c3 else >[SerialNbr] end >,[TranCode] = case substring(@bitmap,1,1) & 8 when 8 then @c4 else >[TranCode] end >,[TransDate] = case substring(@bitmap,1,1) & 16 when 16 then @c5 else >[TransDate] end >,[TransDateShort]= case substring(@bitmap,1,1) & 16 when 16 then >Convert(varchar(10), @c5, 101) else [TransDateShort] end >,[TransDateMonth]= case substring(@bitmap,1,1) & 16 when 16 then Month(@c5) >else [TransDateMonth] end >,[TransDateYear]= case substring(@bitmap,1,1) & 16 when 16 then Year(@c5) >else [TransDateYear] end >,[TransAmt] = case substring(@bitmap,1,1) & 32 when 32 then @c6 else >[TransAmt] end >,[RefNbr] = case substring(@bitmap,1,1) & 64 when 64 then @c7 else [RefNbr] >end >,[MerchName] = case substring(@bitmap,1,1) & 128 when 128 then @c8 else >[MerchName] end >,[City] = case substring(@bitmap,2,1) & 1 when 1 then @c9 else [City] end >,[State] = case substring(@bitmap,2,1) & 2 when 2 then @c10 else [State] end >,[RejectReason] = case substring(@bitmap,2,1) & 4 when 4 then @c11 else >[RejectReason] end
Here is my TransDTL.SQL script. CREATE TABLE [dbo].[TransDtl] ( [TransDtlKey] [int] NOT NULL , [CustomerKey] [int] NULL , [SerialNbr] [char] (10), [TranCode] [char] (4), [TransDate] [smalldatetime] NULL , [TransDateShort] [char] (10), [TransDateMonth] [tinyint] NULL , [TransDateYear] [smallint] NULL , [TransAmt] [money] NULL , [RefNbr] [char] (23), [MerchName] [varchar] (25), [City] [varchar] (15), [State] [varchar] (3), [RejectReason] [varchar] (15), [PostDate] [datetime] NULL , [PostDateShort] [char] (10), [PostDateMonth] [tinyint] NULL , [PostDateYear] [smallint] NULL , [CreateDate] [datetime] NULL , [MerchSIC] [char] (4) ) ON [PRIMARY] GO -- Hilary Cotter Looking for a book on SQL Server replication? http://www.nwsu.com/0974973602.html [quoted text, click to view] "ChrisR" <anonymous@discussions.microsoft.com> wrote in message news:996601c48634$514ae260$a601280a@phx.gbl... > I think Im missing a big part of sometihng here in regards > to Custom Sync Object. (Subscriber has more columns than > Publisher) I can make this work without a Custom Sync > Object. It will work if I use a nosync approach, therefore > not needing to BCP the snapshot to the Subscriber. Please > read on after these schemas and procs. Heres my current > schemas. > > > --Publisher table > CREATE TABLE [dbo].[TransDtl] ( > [TransDtlKey] [int] IDENTITY (1, 1) NOT NULL , > [CustomerKey] [int] NULL , > [SerialNbr] [char] (10) COLLATE > SQL_Latin1_General_CP1_CI_AS NOT NULL , > [TranCode] [char] (4) COLLATE > SQL_Latin1_General_CP1_CI_AS NOT NULL , > [TransDate] [smalldatetime] NOT NULL , > [TransAmt] [money] NOT NULL , > [RefNbr] [char] (23) COLLATE > SQL_Latin1_General_CP1_CI_AS NOT NULL , > [MerchName] [varchar] (25) COLLATE > SQL_Latin1_General_CP1_CI_AS NOT NULL , > [City] [varchar] (15) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [State] [varchar] (3) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [RejectReason] [varchar] (15) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [PostDate] [datetime] NOT NULL , > [CreateDate] [datetime] NOT NULL , > [MerchSIC] [char] (4) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL > ) ON [PRIMARY] > GO > > > --Sub table > CREATE TABLE [dbo].[TransDtl] ( > [TransDtlKey] [int] NOT NULL , > [CustomerKey] [int] NULL , > [SerialNbr] [char] (10) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [TranCode] [char] (4) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [TransDate] [smalldatetime] NULL , > [TransDateShort] [char] (10) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [TransDateMonth] [tinyint] NULL , > [TransDateYear] [smallint] NULL , > [TransAmt] [money] NULL , > [RefNbr] [char] (23) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [MerchName] [varchar] (25) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [City] [varchar] (15) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [State] [varchar] (3) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [RejectReason] [varchar] (15) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [PostDate] [datetime] NULL , > [PostDateShort] [char] (10) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL , > [PostDateMonth] [tinyint] NULL , > [PostDateYear] [smallint] NULL , > [CreateDate] [datetime] NULL , > [MerchSIC] [char] (4) COLLATE > SQL_Latin1_General_CP1_CI_AS NULL > ) ON [PRIMARY] > GO > > > SET QUOTED_IDENTIFIER OFF > GO > SET ANSI_NULLS ON > GO > > > --Insert proc > ALTER procedure sp_msIns_TransDtl > @TransDtlKey int , > @CustomerKey int , > @SerialNbr char (10) , > @TranCode char (4) , > @TransDate smalldatetime , > @TransAmt money , > @RefNbr char (23) , > @MerchName varchar (25) , > @City varchar (15) , > @State varchar (3) , > @RejectReason varchar (15) , > @PostDate datetime , > @CreateDate datetime , > @MerchSIC char (4) > as > > insert into TransDTL > ( > > TransDtlKey , > CustomerKey , > SerialNbr , > TranCode , > TransDate , > TransDateShort , > TransDateMonth , > TransDateYear , > TransAmt , > RefNbr , > MerchName , > City , > State , > RejectReason , > PostDate , > PostDateShort , > PostDateMonth , > PostDateYear , > CreateDate , > MerchSIC > ) > > values > ( > @TransDtlKey , > @CustomerKey , > @SerialNbr , > @TranCode , > @TransDate , > Convert(varchar(10), @TransDate, 101), > Month(@TransDate) , > Year(@TransDate), > @TransAmt , > @RefNbr , > @MerchName , > @City , > @State , > @RejectReason , > @PostDate , > Convert(varchar(10), @PostDate, 101) , > Month(@PostDate), > Year(@PostDate) , > @CreateDate , > @MerchSIC > ) > > > GO > SET QUOTED_IDENTIFIER OFF > GO > SET ANSI_NULLS ON > GO > > As mentioned, the above works for individual inserts. Of > course not for the initial snapshot. Which is what I > thought a Custom Sync Object could handle. > > > > I had also hoped that with a Custom Sync Object and > telling the article to use it(below), I would be able to > BCP the data for the Snapshot. But that blows up with an > EOF. I think Im missing something big here??? > > > create view SyncTransDTL > as select > TransDtlKey , > CustomerKey , > SerialNbr , > TranCode , > TransDate , > TransDateShort = Convert(varchar(10), TransDate, 101), > TransDateMonth = Month(TransDate), > TransDateYear = Year(TransDate), > TransAmt , > RefNbr , > MerchName , > City , > State , > RejectReason , > PostDate , > PostDateShort = Convert(varchar(10), PostDate, 101), > PostDateMonth = Month(PostDate), > PostDateYear = Year(PostDate), > CreateDate , > MerchSIC > from dbo.transdtl > > > sp_addarticle @publication = 'transdtl' > , @article = 'transdtl' > , @source_table = 'transdtl' > , @destination_table = 'transdtl' > , @type = 'logbased manualview' > , @sync_object = 'SyncTransDTL' > , @creation_script > = '\\location\d$\Replication\CreateTransDTL.txt' > ,@ins_cmd = 'CALL sp_MSins_TransDTL' > ,@del_cmd = 'CALL sp_MSdel_TransDTL' > ,@upd_cmd = 'MCALL sp_MSupd_TransDTL' > ,@schema_option = 0x00 > ,@status = 8 >
This works for me. Can you do a select @@version on your SQL Server and post it back here? create database ChrisR go create database ChrisRSub go use ChrisR go CREATE TABLE TransDtl ( TransDtlKey int IDENTITY(1, 1) NOT NULL PRIMARY KEY, CustomerKey int NULL, SerialNbr char(10), TranCode char(4), TransDate smalldatetime NOT NULL, TransAmt money NOT NULL, RefNbr char(23), MerchName varchar(25), City varchar(15), State varchar(3), RejectReason varchar(15), PostDate datetime NOT NULL, CreateDate datetime NOT NULL, MerchSIC char(4) ) GO use chrisr GO Create View CustomSyncObject as select TransDtlKey=convert(int,TransDtlKey), CustomerKey=convert(int,CustomerKey), SerialNbr=convert(char(10),SerialNbr), TranCode=convert(char(4),TranCode), TransDate=convert(smalldatetime,TransDate), TransDateShort = Convert(varchar(10),TransDate, 101), TransDateMonth = convert(tinyint,Month(TransDate)), TransDateYear = convert(smallint,Year(TransDate)), TransAmt=convert(money, TransAmt), RefNbr, MerchName, City, State, RejectReason, PostDate, PostDateShort = Convert(varchar(10), PostDate, 101), PostDateMonth = convert(tinyint, Month(PostDate)), PostDateYear=convert(smallint, Year(PostDate)), CreateDate, MerchSIC from TransDtl GO sp_dboption 'ChrisR','published','true' go sp_addpublication 'ChrisR',@status='active', @sync_method = N'character' go sp_addpublication_snapshot 'ChrisR' go sp_addarticle @publication = 'ChrisR', @article = 'TransDTL', @source_object = 'TransDTL', @destination_table = 'TransDTL', @type = 'logbased manualview', @sync_object='CustomSyncObject', @creation_script = 'c:\temp\TransDTL.sql', @pre_creation_cmd = 'delete', @schema_option = 0x0, @status = 8, @ins_cmd = 'CALL sp_MSins_TransDTL', @del_cmd = 'CALL sp_MSdel_TransDTL', @upd_cmd = 'MCALL sp_MSupd_TransDTL' GO use chrisRsub go if exists (select * from sysobjects where type = 'P' and name = 'sp_MSins_TransDTL') drop proc [sp_MSins_TransDTL] go create procedure [sp_MSins_TransDTL] @c1 int,@c2 int,@c3 char(10),@c4 char(4),@c5 smalldatetime,@c6 money,@c7 char(23),@c8 varchar(25),@c9 varchar(15),@c10 varchar(3),@c11 varchar(15),@c12 datetime,@c13 datetime,@c14 char(4) AS BEGIN insert into [TransDTL]( [TransDtlKey], [CustomerKey], [SerialNbr], [TranCode], [TransDate],[TransDateShort], [TransDateMonth], [TransDateYear], [TransAmt], [RefNbr], [MerchName], [City], [State], [RejectReason], [PostDate],[PostDateShort],[PostDateMonth],[PostDateYear], [CreateDate], [MerchSIC] ) values ( @c1, @c2, @c3, @c4, @c5, Convert(varchar(10), @c5, 101), Month(@c5), Year(@c5), @c6, @c7, @c8, @c9, @c10, @c11, @c12, Convert(varchar(10), @c12, 101), Month(@c12), Year(@c12), @c13, @c14 ) END go if exists (select * from sysobjects where type = 'P' and name = 'sp_MSupd_TransDTL') drop proc [sp_MSupd_TransDTL] go create procedure [sp_MSupd_TransDTL] @c1 int,@c2 int,@c3 char(10),@c4 char(4),@c5 smalldatetime,@c6 money,@c7 char(23),@c8 varchar(25),@c9 varchar(15),@c10 varchar(3),@c11 varchar(15),@c12 datetime,@c13 datetime,@c14 char(4),@pkc1 int ,@bitmap binary(2) as if substring(@bitmap,1,1) & 1 = 1 begin update [TransDTL] set [TransDtlKey] = case substring(@bitmap,1,1) & 1 when 1 then @c1 else [TransDtlKey] end ,[CustomerKey] = case substring(@bitmap,1,1) & 2 when 2 then @c2 else [CustomerKey] end ,[SerialNbr] = case substring(@bitmap,1,1) & 4 when 4 then @c3 else [SerialNbr] end ,[TranCode] = case substring(@bitmap,1,1) & 8 when 8 then @c4 else [TranCode] end ,[TransDate] = case substring(@bitmap,1,1) & 16 when 16 then @c5 else [TransDate] end ,[TransDateShort]= case substring(@bitmap,1,1) & 16 when 16 then Convert(varchar(10), @c5, 101) else [TransDateShort] end ,[TransDateMonth]= case substring(@bitmap,1,1) & 16 when 16 then Month(@c5) else [TransDateMonth] end ,[TransDateYear]= case substring(@bitmap,1,1) & 16 when 16 then Year(@c5) else [TransDateYear] end ,[TransAmt] = case substring(@bitmap,1,1) & 32 when 32 then @c6 else [TransAmt] end ,[RefNbr] = case substring(@bitmap,1,1) & 64 when 64 then @c7 else [RefNbr] end ,[MerchName] = case substring(@bitmap,1,1) & 128 when 128 then @c8 else [MerchName] end ,[City] = case substring(@bitmap,2,1) & 1 when 1 then @c9 else [City] end ,[State] = case substring(@bitmap,2,1) & 2 when 2 then @c10 else [State] end ,[RejectReason] = case substring(@bitmap,2,1) & 4 when 4 then @c11 else [RejectReason] end ,[PostDate] = case substring(@bitmap,2,1) & 8 when 8 then @c12 else [PostDate] end ,[PostDateShort] = case substring(@bitmap,2,1) & 8 when 8 then Convert(varchar(10), @c12, 101) else [PostDateShort] end ,[PostDateMonth] = case substring(@bitmap,2,1) & 8 when 8 then Month(@c12) else [PostDateMonth] end ,[PostDateYear] = case substring(@bitmap,2,1) & 8 when 8 then Year(@c12) else [PostDateYear] end ,[CreateDate] = case substring(@bitmap,2,1) & 16 when 16 then @c13 else [CreateDate] end ,[MerchSIC] = case substring(@bitmap,2,1) & 32 when 32 then @c14 else [MerchSIC] end where [TransDtlKey] = @pkc1 if @@rowcount = 0 if @@microsoftversion>0x07320000 exec sp_MSreplraiserror 20598 end else begin update [TransDTL] set [CustomerKey] = case substring(@bitmap,1,1) & 2 when 2 then @c2 else [CustomerKey] end ,[SerialNbr] = case substring(@bitmap,1,1) & 4 when 4 then @c3 else [SerialNbr] end ,[TranCode] = case substring(@bitmap,1,1) & 8 when 8 then @c4 else [TranCode] end ,[TransDate] = case substring(@bitmap,1,1) & 16 when 16 then @c5 else [TransDate] end ,[TransDateShort]= case substring(@bitmap,1,1) & 16 when 16 then Convert(varchar(10), @c5, 101) else [TransDateShort] end ,[TransDateMonth]= case substring(@bitmap,1,1) & 16 when 16 then Month(@c5) else [TransDateMonth] end ,[TransDateYear]= case substring(@bitmap,1,1) & 16 when 16 then Year(@c5) else [TransDateYear] end ,[TransAmt] = case substring(@bitmap,1,1) & 32 when 32 then @c6 else [TransAmt] end ,[RefNbr] = case substring(@bitmap,1,1) & 64 when 64 then @c7 else [RefNbr] end ,[MerchName] = case substring(@bitmap,1,1) & 128 when 128 then @c8 else [MerchName] end ,[City] = case substring(@bitmap,2,1) & 1 when 1 then @c9 else [City] end ,[State] = case substring(@bitmap,2,1) & 2 when 2 then @c10 else [State] end ,[RejectReason] = case substring(@bitmap,2,1) & 4 when 4 then @c11 else [RejectReason] end ,[PostDate] = case substring(@bitmap,2,1) & 8 when 8 then @c12 else [PostDate] end ,[PostDateShort] = case substring(@bitmap,2,1) & 8 when 8 then Convert(varchar(10), @c12, 101) else [PostDateShort] end ,[PostDateMonth] = case substring(@bitmap,2,1) & 8 when 8 then Month(@c12) else [PostDateMonth] end ,[PostDateYear] = case substring(@bitmap,2,1) & 8 when 8 then Year(@c12) else [PostDateYear] end ,[CreateDate] = case substring(@bitmap,2,1) & 16 when 16 then @c13 else [CreateDate] end ,[MerchSIC] = case substring(@bitmap,2,1) & 32 when 32 then @c14 else
Don't see what you're looking for? Try a search.
|