-- first check if the row exists...
if (select count(*) from tab1 where tab1_id = 23) = 1
-- the generation script knows that tab1_id is the primary key
update tab1 set tab1_data1 = <data1 from source table>, tab1_data2 =
<data2 from source..> where tab1_id = 23
else
-- the row doesn't exist on target table so insert it...
insert tab1 (tab1_id, tab1_data1, tab1_data2) values
( 23, <data1 from source table>, tab1_data2 = <data2 from source>)
It would also be nice to make the tables the same as far as deletes (rows
that have been removed on the source are also removed on the target) but I
can't figure out how to determine this in a batch mode.
If you've written something like this, or have seen something like this, or
even can can tell me how to coerse the rep-server to simulate all the data
in the table and capture it to a script, I'd be very appreciative for any
help. Thanks, D Shapiro/Nextcard.
> If you've written something like this, or have seen something like this, or
> even can can tell me how to coerse the rep-server to simulate all the data
> in the table and capture it to a script, I'd be very appreciative for any
> help. Thanks, D Shapiro/Nextcard.
Something like this ?
CREATE PROCEDURE REPL_Categories (
@CheckDate SmallDateTime
)
AS
BEGIN TRAN
DELETE FROM Categories
WHERE NOT EXISTS (SELECT CategoryId FROM CAT_Categories
WHERE CategoryAuto = Categories.CategoryAuto)
UPDATE Categories
SET CategoryName = C.CategoryName
FROM CAT_Categories C
WHERE C.CategoryId = Categories.CategoryId
AND C.LastChanged > @CheckDate
INSERT INTO Categories (CategoryAuto, CategoryId,
CategoryName, Langu)
SELECT CategoryAuto, CategoryId, CategoryName, Langu
FROM CAT_Categories
WHERE NOT EXISTS (SELECT CategoryId FROM Categories WHERE
CategoryAuto = CAT_Categories.CategoryAuto)
--
Gorm Larsen
Hjælp til XAL og AxApta? Abonner på news.tadorna.dk