Showing posts with label wether. Show all posts
Showing posts with label wether. Show all posts

Monday, March 12, 2012

How to find out wether a row has been replicated?

Dear ppl,

In Merge Replication SQL Server2005, what is the easiest way of finding out wether a row on the publisher database has ever been replicated to subscribers?

Regards

Nabeel-

The procedure below should get you started on being able to tell if a row has been sent to a subscriber, all you need to do is provide the rowguid and publication name.

use <PUB_DB_NAME>

go

create procedure ASubHasIt(@.pubname sysname, @.row uniqueidentifier)

as

declare @.tablenick int

declare @.maxsentgen int

select @.maxsentgen = max(sentgen), @.tablenick = max(nickname) from (sysmergesubscriptions sms join sysmergepublications smp on sms.pubid = smp.pubid) join sysmergearticles sma on sma.pubid=smp.pubid where smp.name='PubName' and sms.sentgen IS NOT NULL

if exists (select * from MSmerge_genhistory gh join MSmerge_contents mc on mc.generation = gh.generation where gh.generation > @.maxsentgen and mc.rowguid = @.row)

begin

print 'Row ' + CONVERT(nvarchar(max), @.row) + ' has NOT been sent to a subscriber'

end

else

begin

print 'Row ' + CONVERT(nvarchar(max), @.row) + ' has been sent to a subscriber'

end

go

Example:

exec ASubHasIt @.pubname='PubName', @.row='8B348C04-B3A9-DB11-AEA6-000BDBD0506C'

Hope this helps!

-Phil Piwonka

|||excellent...cheers mate :)

Sunday, February 19, 2012

how to find a substring in a string

I guess my question is that in my sp how can I make sure wether a substring
exists ina string or not.I'm using this now,is there something better :
SELECT @.tempString = REPLACE(UPPER(mySpParamter),'MEMBER','wo
w!')
IF @.tempString <> mySpParamter --This means that the MEMBER keyword is
part of the word
BEGIN
SET @.ClientType='MB'
END
thanksHow about :
If myspParamter like '%MEMBER%'
Begin
....
"Ray5531" wrote:

> I guess my question is that in my sp how can I make sure wether a substrin
g
> exists ina string or not.I'm using this now,is there something better :
> SELECT @.tempString = REPLACE(UPPER(mySpParamter),'MEMBER','wo
w!')
> IF @.tempString <> mySpParamter --This means that the MEMBER keyword is
> part of the word
> BEGIN
> SET @.ClientType='MB'
> END
>
> thanks
>
>|||Yours better,
Thanks
"dtbascent" <dtbascent@.discussions.microsoft.com> wrote in message
news:8FC6472D-4705-4753-AB47-B5DD1C0A2AE6@.microsoft.com...
> How about :
> If myspParamter like '%MEMBER%'
> Begin
> .....
> "Ray5531" wrote:
>|||Hi
Looks like 'MEMBER' will never exist in @.tempString because its replaced
with 'wow!'
best Regards,
Chandra
http://chanduas.blogspot.com/
---
"dtbascent" wrote:
> How about :
> If myspParamter like '%MEMBER%'
> Begin
> .....
> "Ray5531" wrote:
>|||yes,that's the key
then I check if it's different it mean it has been located(exists) and if it
dosen't exists replace returns the original string.
Thanks
"Chandra" <Chandra@.discussions.microsoft.com> wrote in message
news:BF8E3946-DB9D-410F-A6E2-40106B478976@.microsoft.com...
> Hi
> Looks like 'MEMBER' will never exist in @.tempString because its replaced
> with 'wow!'
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> ---
>
> "dtbascent" wrote:
>