Hi!
I have a schema that looks like this, on my main server:
tableFiles:
FileID (PK)
FileName
table FileProperties
PropertyID
FileID (FK Files.FileID) (PK)
PropertyName (PK)
PropertyValue
table Hosts_Files
HostName (PK)
FileID (PK)
Now what I want to achieve is this:
There are many clients that use this database. Sometimes they go
offline and take some of the files with them to work offline.
When this occurs, I want to replicate the entire table Files, and only
the rows from FileProperties that have to do with the files they
downloaded to their computer (marked so in Hosts_Files).
Can I make this work with merge replication? I tried but the dynamic
filters I can write are either JOIN or WHERE (or am I wrong?) so I
couldn't manage to do a join between FileProperties and Hosts_Files
only where Hosts_Files.HostName = host_name().
Thanks in advance for answering,
Zzzbla
You could join these tables in the merge publication. Filtering in this case
is a bit tricky as it looks as though you want to change the filter
effectively dynamically. I'm assuming that there is a typo somewhere, as
this doesn't seem to make logical sense: "I want to replicate the entire
table Files, and only the rows from FileProperties that have to do with the
files they downloaded to their computer" - this would seem to imply all
FileProperties. The way I read your requirements are that you want users to
select certain files and have just associated details downloaded? If this is
the case, you can have a further table which relates fileids to hostnames.
Selecting to download a file will cause an insert of a record in this new
table. All tables would be joined on fileid, and the dynamic filter would be
solely to the new table.
HTH,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||Hi Paul,
I forgot to mention that the rows in the files table correlate to
physical files. So what I wanted is to have some *physical* files
downloaded to the client's computer, all of the rows in the files table
(the client may have to see or use data about files that he didn't
download) and only the rows in the fileproperties table that are
related to the few rows in files table that are related to the physical
files the user downloaded.
I know I can join the tables - FileProperties and the table that
associates the fileid to the hostname - but when I also need to use
WHERE Hosts_Files.HostName = host_name(). I tried to do it but the
replication wizard doesn't let me.
If you could provide me with a script or an example solution (or is it
just a view that I have to write in order to combine JOIN and WHERE
filters?), I'll be grateful.
Thanks in advance,
Zzzbla
Paul Ibison wrote:
> You could join these tables in the merge publication. Filtering in
> this case is a bit tricky as it looks as though you want to change
the
> filter effectively dynamically. I'm assuming that there is a typo
> somewhere, as this doesn't seem to make logical sense: "I want to
> replicate the entire table Files, and only the rows from
> fileProperties that have to do with the files they downloaded to
their
> computer" - this would seem to imply all FileProperties. The way I
> read your requirements are that you want users to select certain
files
> and have just associated details downloaded? If this is the case,
you
> can have a further table which relates fileids to hostnames.
Selecting
> to download a file will cause an insert of a record in this new
table.
> All tables would be joined on fileid, and the dynamic filter would be
> solely to the new table.
> Paul Ibison SQL Server MVP, www.replicationanswers.com
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
|||Some additions:
The real problem I'm facing is that the table I want to filter by
(Hosts_Files) is only related to the table I want to filter
(FileProperties) via the table Files - which I want to leave unfiltered.
If I let it filter the files table, I get the FileProperties I wanted,
but I also get only the selected rows from files and not the whole
table as required.
I wouldn't want to create a Hosts_FileProperties unless there's no
better solution...
|||Please post up the schema of hte tables involved and I'll have a look. A
(denormalized) linking table will work (maintained by triggers) but there
might be an alternative.
HTH,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||Hi,
I attached a script to create tables and relationships.
Thank you for your time and effort!
begin 444 replication test.sql
M__YI`&8`(`!E`'@.`:0!S`'0`<P`@.`"@.`<P!E`&P`90!C`'0`( ``J`"``9@.!R
M`&\`;0`@.`&0`8@.!O`"X`<P!Y`',`;P!B`&H`90!C`'0`<P`@.` '<`:`!E`'(`
M90`@.`&D`9``@.`#T`(`!O`&(`:@.!E`&,`=`!?`&D`9``H`$X`) P!;`&0`8@.!O
M`%T`+@.!;`$8`2P!?`$8`:0!L`&4`4`!R`&\`<`!E`'(`=`!I` &4`<P!?`$8`
M:0!L`&4`<P!=`"<`*0`@.`&$`;@.!D`"``3P!"`$H`10!#`%0`4 `!2`$\`4`!%
M`%(`5`!9`"@.`:0!D`"P`(`!.`"<`20!S`$8`;P!R`&4`:0!G` &X`2P!E`'D`
M)P`I`"``/0`@.`#$`*0`-``H`00!,`%0`10!2`"``5`!!`$(`3`!%`"``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6P!D`&(`;P!=`"X`6P!&`&D`;`!E`%``<@.!O`'``90!R`'0`: 0!E`',`70`@.
M`$$`1`!$`"``#0`*``D`0P!/`$X`4P!4`%(`00!)`$X`5``@.`%L`1@.!+`%\`
M1@.!I`&P`90!0`'(`;P!P`&4`<@.!T`&D`90!S`%\`1@.!I`&P`9 0!S`%T`(`!&
M`$\`4@.!%`$D`1P!.`"``2P!%`%D`(``-``H`"0`H``T`"@.`)``D`6P!&`&D`
M;`!E`$D`1`!=``T`"@.`)`"D`(`!2`$4`1@.!%`%(`10!.`$,`1 0!3`"``6P!D
M`&(`;P!=`"X`6P!&`&D`;`!E`',`70`@.`"@.`#0`*``D`"0!;` $8`:0!L`&4`
M20!$`%T`#0`*``D`*0`@.`$\`3@.`@.`$0`10!,`$4`5`!%`"``0 P!!`%,`0P!!
M`$0`10`@.``T`"@.!'`$\`#0`*``T`"@.!!`$P`5`!%`%(`(`!4` $$`0@.!,`$4`
M(`!;`&0`8@.!O`%T`+@.!;`$@.`;P!S`'0`<P!?`$8`:0!L`&4`< P!=`"``00!$
M`$0`(``-``H`"0!#`$\`3@.!3`%0`4@.!!`$D`3@.!4`"``6P!&`$L`7P!(`& \`
M<P!T`',`7P!&`&D`;`!E`',`7P!&`&D`;`!E`',`70`@.`$8`3 P!2`$4`20!'
M`$X`(`!+`$4`60`@.``T`"@.`)`"@.`#0`*``D`"0!;`$8`:0!L` &4`20!$`%T`
M#0`*``D`*0`@.`%(`10!&`$4`4@.!%`$X`0P!%`%,`(`!;`&0`8 @.!O`%T`+@.!;
M`$8`:0!L`&4`<P!=`"``*``-``H`"0`)`%L`1@.!I`&P`90!)`$0`70`-``H`
4"0`I``T`"@.!'`$\`#0`*``T`"@.``
end
|||As far as I can see, removing the Files properties out of the equation
satisfies these requirements:
Filter:
SELECT <published_columns> FROM [dbo].[Hosts_Files] WHERE
hostname = HOST_NAME()
Join:
SELECT <published_columns> FROM [dbo].[Hosts_Files] INNER JOIN
[dbo].[FileProperties] ON [FileProperties].[FileID] =
[FileProperties].[FileID]
(publication script attached).
HTH,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
begin 666 replication test.sql
M__XM`"T`( !!`&0`9 !I`&X`9P`@.`'0`: !E`" `;0!E`'(`9P!E`" `< !U
M`&(`; !I`&,`80!T`&D`;P!N``T`"@.!E`'@.`90!C`" `<P!P`%\`80!D`&0`
M;0!E`'(`9P!E`' `=0!B`&P`:0!C`&$`= !I`&\`;@.`@.`$ `< !U`&(`; !I
M`&,`80!T`&D`;P!N`" `/0`@.`$X`)P!8`%@.`6 !4`&4`<P!T`"<`+ `@.`$ `
M9 !E`',`8P!R`&D`< !T`&D`;P!N`" `/0`@.`$X`)P!-`&4`<@.!G`&4`( !P
M`'4`8@.!L`&D`8P!A`'0`:0!O`&X`( !O`&8`( !8`%@.`6 `@.`&0`80!T`&$`
M8@.!A`',`90`@.`&8`<@.!O`&T`( !0`'4`8@.!L`&D`<P!H`&4`<@.`@.`%@.`6 !8
M`"X`)P`L`" `0 !R`&4`= !E`&X`= !I`&\`;@.`@.`#T`( `Q`#0`+ `@.`$ `
M<P!Y`&X`8P!?`&T`;P!D`&4`( `]`" `3@.`G`&X`80!T`&D`=@.!E`"<`+ `@.
M`$ `80!L`&P`;P!W`%\`< !U`',`: `@.`#T`( !.`"<`= !R`'4`90`G`"P`
M( ! `&$`; !L`&\`=P!?`' `=0!L`&P`( `]`" `3@.`G`'0`<@.!U`&4`)P`L
M`" `0 !A`&P`; !O`'<`7P!A`&X`;P!N`'D`;0!O`'4`<P`@.`#T`( !.`"<`
M9@.!A`&P`<P!E`"<`+ `@.`$ `90!N`&$`8@.!L`&4`9 !?`&8`;P!R`%\`:0!N
M`'0`90!R`&X`90!T`" `/0`@.`$X`)P!F`&$`; !S`&4`)P`L`" `0 !C`&4`
M;@.!T`'(`80!L`&D`>@.!E`&0`7P!C`&\`;@.!F`&P`:0!C`'0`< P`@.`#T`( !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@.!G`" `= !H`&4`( !A
M`'(`= !I`&,`; !E`" `<P!U`&(`<P!E`'0`( !F`&D`; !T`&4`<@.`-``H`
M90!X`&4`8P`@.`',`< !?`&$`9 !D`&T`90!R`&<`90!F`&D`; !T`&4`<@.`@.
M`$ `< !U`&(`; !I`&,`80!T`&D`;P!N`" `/0`@.`$X`)P!8`%@.`6 !4`&4`
M<P!T`"<`+ `@.`$ `80!R`'0`:0!C`&P`90`@.`#T`( !.`"<`1@.!I`&P`90!0
M`'(`;P!P`&4`<@.!T`&D`90!S`"<`+ `@.`$ `9@.!I`&P`= !E`'(`;@.!A`&T`
M90`@.`#T`( !.`"<`1@.!+`%\`1@.!I`&P`90!0`'(`;P!P`&4`<@.!T`&D`90!S
M`%\`1@.!I`&P`90!S`"<`+ `@.`$ `:@.!O`&D`;@.!?`&$`<@.!T`&D`8P!L`&4`
M;@.!A`&T`90`@.`#T`( !.`"<`2 !O`',`= !S`%\`1@.!I`&P`90!S`"<`+ `@.
M`$ `:@.!O`&D`;@.!?`&8`:0!L`'0`90!R`&,`; !A`'4`<P!E`" `/0`@.`$X`
M)P!;`$8`:0!L`&4`4 !R`&\`< !E`'(`= !I`&4`<P!=`"X`6P!&`&D`; !E
M`$D`1 !=`" `/0`@.`%L`1@.!I`&P`90!0`'(`;P!P`&4`<@.!T`&D`90!S`%T`
M+@.!;`$8`:0!L`&4`20!$`%T`)P`L`" `0 !J`&\`:0!N`%\`=0!N`&D`<0!U
C`&4`7P!K`&4`>0`@.`#T`( `P``T`"@.!'`$\`#0`*``T`"@.``
`
end
|||Hi Paul,
Thank you. That's what I've been trying to do, but the enterprise
manager kept telling me that Hosts_Files and FileProperties are not
related...
I ran the script you attached but unfortunatly - it still doesn't work.
The subscriber still gets the whole FileProperties table and not only
the properties for the files in Hosts_Files.
Have you got any idea why this isn't working?
Thank you again.
Paul Ibison wrote:
> As far as I can see, removing the Files properties out of the
> equation satisfies these requirements:
> Filter:
> SELECT <published_columns> FROM [dbo].[Hosts_Files] WHERE
> hostname = HOST_NAME()
> Join:
> SELECT <published_columns> FROM [dbo].[Hosts_Files] INNER JOIN
> [dbo].[FileProperties] ON [FileProperties].[FileID] =
> [FileProperties].[FileID]
> (publication script attached).
> HTH,
> Paul Ibison SQL Server MVP, www.replicationanswers.com
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
|||I don't know why you get this error message from EM but the script runs. As
far as the publication I posted up goes you're quite right - I just tested
this and only the table directly related to the host_name() function is
filtered. Interesting! The other option is to use the host_name function on
the file_properties table as well. I know that this isn't related to host
names, but we can make it related by using a UDF.
HTH,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||Thank you for your fast and helpful replies.
Well, in this case now when the obvious fails, I'm left with two
options:
- FILTER FileProperties with a user defined function, or
- JOINing FileProperties with a new table that has hostname and
FilePropertyID.
The first one probably has a cost in querying, and the second one in
inserting. Which one in your opinion is better? Also, if I use a user
defined function, should I pass HOST_NAME() as a parameter to it in the
filter, or simply use HOST_NAME() in the function itself (i.e. not as a
parameter)?
Monday, February 20, 2012
Merge replication and dynamic filters question
Labels:
database,
dynamic,
fileid,
filenametable,
filepropertiespropertyidfileid,
files,
filters,
hii,
merge,
microsoft,
mysql,
oracle,
replication,
schema,
server,
servertablefilesfileid,
sql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment