Quantcast
Channel: SQL Server Replication forum
Viewing all articles
Browse latest Browse all 4054

Error durring intial syncronization. The schema script 'f_CINARelatedParties_377.sch' could not be propagated to the subscriber.

$
0
0

Merge push (also tried pull, same error). MS server 2008 R2 and SQL server 2008 R2.

Full error from job is below followed by f_CINARelatedParties Function. this Function has not changed and I do this configuration evey couple of weeks. I did not write the Function.

2012-09-25 22:05:08.167 The schema script 'f_CINARelatedParties_377.sch' could not be propagated to the subscriber.

2012-09-25 22:05:08.978 Category:NULL

Source:  Merge Replication Provider

Number:  -2147201001

Message: The schema script 'f_CINARelatedParties_377.sch' could not be propagated to the subscriber.

2012-09-25 22:05:08.983 Category:NULL

Source:  Microsoft SQL Server Native Client 10.0

Number:  421

Message: The text data type cannot be selected as DISTINCT because it is not comparable.

drop Function [dbo].[f_CINARelatedParties]

go

SET QUOTED_IDENTIFIER ON

go

SET ANSI_NULLS ON

go

/*

Author:  Sophus Consulting

Date:    March 2012

Purpose: Called by calc in CINA doc types to return names of parties related to children selected as Addressees in Recipients grid.

                                Also returns related party relationship and address (or date of birth) if specified in calc.

*/

CREATE FUNCTION [dbo].[f_CINARelatedParties](@Events varchar(36),@SelectList varchar(1000),@Relationship varchar(20),@Address varchar(20))

RETURNS VARCHAR(8000) AS

BEGIN

                declare @delim char(1)

                set @delim=','

                SET @SelectList=rtrim(ltrim(replace(replace(@selectlist,' ,',','),', ',',')))

                IF charindex('paternal',@selectlist)=0 and charindex('maternal',@selectlist)=0

                BEGIN

                                set @selectlist=replace(@selectlist,'grandfather','maternal grandfather,paternal grandfather')

                                set @selectlist=replace(@selectlist,'grandmother','maternal grandmother,paternal grandmother')

                END

                DECLARE @list varchar(8000)

                DECLARE @CINA_List TABLE (RelatedParty varchar(70), Relationship varchar(40), Children varchar(1000), Address varchar(1000), DOB datetime)

                IF @SelectList='all'

                BEGIN

                                --NOTE: IF IT IS DECIDED THAT RELATED PARTIES SHOULD ONLY BE INCLUDED IF THEY ARE ADDRESSEES,

                                --THEN UNCOMMENT THE PORTIONS BELOW REFERRING TO EC2 AND DR2

                                insert into @CINA_List

                                select c2.fullname, case when q1.qcontactrelatio like 'father%' then 'Father' else coalesce(q1.qcontactrelatio,'Missing Relationship') end, coalesce(dbo.f_ListCINAChildren(@Events,c2.contacts,case when q1.qcontactrelatio like 'father%' then 'Father' else coalesce(q1.qcontactrelatio,'Missing Relationship') end),''), coalesce(c2.addrlines,''), coalesce(c2.qdateofbirth,'')

                                from contacts c1, matterscontacts mc, contacts c2, contactsqrelationships q, contactsqrelations1 q1, eventmatters em, eventscontacts ec1, documentrecipients dr1--, eventscontacts ec2, documentrecipients dr2

                                where em.events=@Events

                                and mc.matters=em.matters

                                and mc.contacts=c1.contacts

                                and mc.mtocclass='cina child'

                                and q.contacts=c1.contacts

                                and q.contactsqrelationships=q1.contactsqrelationships

                                and q1.qcontactname=c2.contacts

                                and ec1.contacts=c1.contacts

                                and ec1.events=@Events

                                and dr1.documentrecipients=ec1.eventscontacts and dr1.isaddressee='Y'

                                --and (q1.qserviceparty='Y' or q1.qcontactrelatio = 'mother' or q1.qcontactrelatio like 'father%' or q1.qcontactrelatio like '%grandfather%' or q1.qcontactrelatio like '%grandmother%') -- per VG 3/29: include only service parties unless mother, father or grandparent

                                and q1.qserviceparty='Y' -- per VG 4/19: include mother and father in All and Service By lists only if ServiceBy=Y

                                --and ec2.contacts=c2.contacts

                                --and ec2.events=@Events

                                --and dr2.documentrecipients=ec2.eventscontacts and dr2.isaddressee='Y'

                END

                ELSE

                IF @SelectList='service' -- this is basically the same as All, above, except it groups by service type and prefaces each group with its service type

                BEGIN

                                --NOTE: IF IT IS DECIDED THAT RELATED PARTIES SHOULD ONLY BE INCLUDED IF THEY ARE ADDRESSEES,

                                --THEN UNCOMMENT THE PORTIONS BELOW REFERRING TO EC2 AND DR2

                                insert into @CINA_List

                                --sub CINA Service By for Replationship; omit list of children

                                --select c2.fullname, case when q1.qcontactrelatio like 'father%' then 'Father' else coalesce(q1.qcontactrelatio,'Missing Relationship') end, coalesce(dbo.f_ListCINAChildren(@Events,c2.contacts,case when q1.qcontactrelatio like 'father%' then 'Father' else coalesce(q1.qcontactrelatio,'Missing Relationship') end),''), cast(coalesce(c2.addrlines,'') as varchar(1000)) + case when coalesce((select min(phoneno) from phone p where p.contacts=c2.contacts and phonetype='fax'),'')<>'' then char(13)+char(10)+'Fax: '+coalesce((select min(phoneno) from phone p where p.contacts=c2.contacts and phonetype='fax'),'') else '' end, coalesce(c2.qdateofbirth,'')

                                select c2.fullname, coalesce(q1.qcinaserviceby,'Via N/A'), '', cast(coalesce(c2.addrlines,'') as varchar(1000)) + case when coalesce((select min(phoneno) from phone p where p.contacts=c2.contacts and phonetype='fax'),'')<>'' then char(13)+char(10)+'Fax: '+coalesce((select min(phoneno) from phone p where p.contacts=c2.contacts and phonetype='fax'),'') else '' end, ''

                                from contacts c1, matterscontacts mc, contacts c2, contactsqrelationships q, contactsqrelations1 q1, eventmatters em, eventscontacts ec1, documentrecipients dr1--, eventscontacts ec2, documentrecipients dr2

                                where em.events=@Events

                                and mc.matters=em.matters

                                and mc.contacts=c1.contacts

                                and mc.mtocclass='cina child'

                                and q.contacts=c1.contacts

                                and q.contactsqrelationships=q1.contactsqrelationships

                                and q1.qcontactname=c2.contacts

                                and ec1.contacts=c1.contacts

                                and ec1.events=@Events

                                and dr1.documentrecipients=ec1.eventscontacts and dr1.isaddressee='Y'

                                and q1.qserviceparty='Y'

                                --and ec2.contacts=c2.contacts

                                --and ec2.events=@Events

                                --and dr2.documentrecipients=ec2.eventscontacts and dr2.isaddressee='Y'

                END

                ELSE

                BEGIN

                                declare @listTable table(ListValue varchar(50))

                                DECLARE @DelimPosition INT

                                SET @DelimPosition = CHARINDEX(@delim, @SelectList)

                                WHILE @DelimPosition > 0

                                BEGIN

                                                INSERT INTO @listTable(ListValue)

                                                                VALUES(ltrim(rtrim(LEFT(@SelectList, @DelimPosition - 1))))

                                                SET @SelectList = right(@SelectList, len(@SelectList) - @DelimPosition)

                                                SET @DelimPosition = CHARINDEX(@delim, @SelectList)

                                END

                                IF len(@SelectList) > 0

                                BEGIN

                                                insert into @listTable(ListValue)

                                                values(@SelectList)

                                END

                                insert into @CINA_List

                                select c2.fullname, case when q1.qcontactrelatio like 'father%' then 'Father' else coalesce(q1.qcontactrelatio,'Missing Relationship') end, coalesce(dbo.f_ListCINAChildren(@Events,c2.contacts,case when q1.qcontactrelatio like 'father%' then 'Father' else coalesce(q1.qcontactrelatio,'Missing Relationship') end),''), coalesce(c2.addrlines,''), coalesce(c2.qdateofbirth,'')

                                from contacts c1, matterscontacts mc, contacts c2, contactsqrelationships q, contactsqrelations1 q1, eventmatters em, eventscontacts ec1, documentrecipients dr1--, eventscontacts ec2, documentrecipients dr2

                                where em.events=@Events

                                and mc.matters=em.matters

                                and mc.contacts=c1.contacts

                                and mc.mtocclass='cina child'

                                and q.contacts=c1.contacts

                                and q.contactsqrelationships=q1.contactsqrelationships

                                and q1.qcontactname=c2.contacts

                                and ec1.contacts=c1.contacts

                                and ec1.events=@Events

                                and dr1.documentrecipients=ec1.eventscontacts and dr1.isaddressee='Y'

                                and (q1.qserviceparty='Y' or q1.qcontactrelatio = 'mother' or q1.qcontactrelatio like 'father%' or q1.qcontactrelatio like '%grandfather%' or q1.qcontactrelatio like '%grandmother%') -- per VG 4/19 (old: VG 3/29): include only service parties unless mother, father or grandparent

                                --and ec2.contacts=c2.contacts

                                --and ec2.events=@Events

                                --and dr2.documentrecipients=ec2.eventscontacts and dr2.isaddressee='Y'

                                and case when left(q1.qcontactrelatio,6)='father' then 'father' else q1.qcontactrelatio end in((select ListValue from @listTable))

                                                UNION

                                select c2.compname, 'Tribe', coalesce(dbo.f_ListCINAChildren(@Events,c2.contacts,'tribe'),''), coalesce(c2.addrlines,''), coalesce(c2.qdateofbirth,'')

                                from contacts c1, matterscontacts mc, contacts c2, eventmatters em, eventscontacts ec1, documentrecipients dr1, contactsqicwa cq, contactsqicwa1 cq1--, eventscontacts ec2, documentrecipients dr2

                                where em.events=@Events

                                and mc.matters=em.matters

                                and mc.contacts=c1.contacts

                                and mc.mtocclass='cina child'

                                and ec1.contacts=c1.contacts

                                and ec1.events=@Events

                                and dr1.documentrecipients=ec1.eventscontacts and dr1.isaddressee='Y'

                                and cq1.contactsqicwa=cq.contactsqicwa

                                and cq.contacts=c1.contacts

                                and cq1.QIFYESCHILDTRIB=c2.contacts

                                and 'tribe' in((select ListValue from @listTable))

                                                UNION

                                select c2.compname, 'Tribe of Mother', coalesce(dbo.f_ListCINAChildren(@Events,c2.contacts,'mother tribe'),''), coalesce(c2.addrlines,''), coalesce(c2.qdateofbirth,'')

                                from contacts c1, matterscontacts mc, contacts c2, eventmatters em, eventscontacts ec1, documentrecipients dr1, contactsqicwa cq, contactsqicwa1 cq1--, eventscontacts ec2, documentrecipients dr2

                                where em.events=@Events

                                and mc.matters=em.matters

                                and mc.contacts=c1.contacts

                                and mc.mtocclass='cina child'

                                and ec1.contacts=c1.contacts

                                and ec1.events=@Events

                                and dr1.documentrecipients=ec1.eventscontacts and dr1.isaddressee='Y'

                                and cq1.contactsqicwa=cq.contactsqicwa

                                and cq.contacts=c1.contacts

                                and cq1.QIFYESPARENTTRI=c2.contacts

                                and 'tribe of mother' in((select ListValue from @listTable))

                                                UNION

                                select c2.compname, 'Tribe of Father', coalesce(dbo.f_ListCINAChildren(@Events,c2.contacts,'father tribe'),''), coalesce(c2.addrlines,''), coalesce(c2.qdateofbirth,'')

                                from contacts c1, matterscontacts mc, contacts c2, eventmatters em, eventscontacts ec1, documentrecipients dr1, contactsqicwa cq, contactsqicwa1 cq1--, eventscontacts ec2, documentrecipients dr2

                                where em.events=@Events

                                and mc.matters=em.matters

                                and mc.contacts=c1.contacts

                                and mc.mtocclass='cina child'

                                and ec1.contacts=c1.contacts

                                and ec1.events=@Events

                                and dr1.documentrecipients=ec1.eventscontacts and dr1.isaddressee='Y'

                                and cq1.contactsqicwa=cq.contactsqicwa

                                and cq.contacts=c1.contacts

                                and cq1.QIFYESFATHERTRI=c2.contacts

                                and 'tribe of father' in((select ListValue from @listTable))

                END

                IF @SelectList='service'

                BEGIN

                                declare @ServiceBy varchar(40)

                                declare @PrevServiceBy varchar(40)

                                declare @Name varchar(70)

                                declare @Addr varchar(1000)

                                DECLARE CursorList CURSOR FOR

                                                select distinct relationship, relatedparty, address -- relationship is being used for Service Type

                                                from @cina_list

                                                order by relationship

                                OPEN CursorList

                                FETCH NEXT FROM CursorList INTO @ServiceBy, @Name, @Addr

                                set @PrevServiceBy='x'

                                set @List=''

                                WHILE @@FETCH_STATUS = 0

                                BEGIN

                                                IF @ServiceBy<>@PrevServiceBy

                                                BEGIN

                                                                set @List = @List + @ServiceBy+':' + char(13)+char(10)

                                                                set @PrevServiceBy=@ServiceBy

                                                END

                                                set @List = @List + char(9) + @Name + char(13)+char(10)+char(9) + replace(@Addr,char(13)+char(10),char(13)+char(10)+char(9)) + char(13)+char(10)+char(13)+char(10)

                                                FETCH NEXT FROM CursorList INTO @ServiceBy, @Name, @Addr

                                END

                                CLOSE CursorList

                                DEALLOCATE CursorList

                END

                ELSE

                BEGIN

                                DECLARE @CINA_List_Distinct TABLE (RelatedParty varchar(70), Relationship varchar(40), Children varchar(1000), Address varchar(1000), DOB datetime)

                                insert into @CINA_List_Distinct

                                select * from

                                (select top 100 * from

                                (select distinct * from @CINA_List) x

                                order by relationship) y

                                order by case relationship

                                                when 'mother' then 1

                                                when 'father' then 2

                                                when 'maternal grandmother' then 3

                                                when 'maternal grandfather' then 4

                                                when 'paternal grandmother' then 5

                                                when 'paternal grandfather' then 6

                                                else 7

                                                end

                                --the commented out line lists children for all parties EXCEPT mother:

                                --SELECT @list=COALESCE(@list+char(13),'')+relatedparty + ', ' + relationship + case when relationship<>'mother' then case when relationship like '%worker%' then ' for' when relationship like '%representative%' then ' for' when relationship like '%guardian ad litem%' then ' for' else ' of' end + ' ' + children else '' end + case when @Address='address' then char(13)+char(10)+@Address else '' end

                                --the following version lists children only for father:

                                --SELECT @list=COALESCE(@list+char(13),'')+relatedparty + ', ' + case when relationship like 'father%' then + 'Father of ' + children else relationship end + case when @Address='address' then char(13)+char(10)+address else '' end

                                SELECT @list=

                --                             case when @Address='noaddress'

                --                                             then COALESCE(@list+char(13),'')+relatedparty + ', ' + case when relationship like 'father%' then + 'father of ' + children else relationship end

                --                                             else COALESCE(@list+char(13)+char(13),'')+relatedparty + ', ' + case when relationship like 'father%' then + 'father of ' + children else relationship end + char(13) + coalesce(Address,'')

                --                             end

                                                case @Address

                                                                when 'noaddress' then COALESCE(@list+char(13),'')+relatedparty + case when @Relationship='relationship' then ', ' + case when relationship like 'father%' then + 'Father of ' + children else case when relationship = 'tribe of father' then + 'Tribe of Father of ' + children else case when relationship = 'tribe' then + 'Tribe of ' + children else relationship end end end else '' end

                                                                when 'address' then COALESCE(@list+char(13)+char(13),'')+relatedparty + case when @Relationship='relationship' then ', ' + case when relationship like 'father%' then + 'Father of ' + children else case when relationship = 'tribe of father' then + 'Tribe of Father of ' + children else case when relationship = 'tribe' then + 'Tribe of ' + children else relationship end end end else '' end + char(13) + coalesce(Address,'')

                                                                when 'address,' then COALESCE(@list+char(13)+char(13),'')+relatedparty + case when @Relationship='relationship' then ', ' + case when relationship like 'father%' then + 'Father of ' + children else case when relationship = 'tribe of father' then + 'Tribe of Father of ' + children else case when relationship = 'tribe' then + 'Tribe of ' + children else relationship end end end else '' end + ', ' + replace(coalesce(Address,''),char(13)+char(10),', ')

                                                                when 'addressonly' then COALESCE(@list+char(13)+char(13),'') + coalesce(Address,'')

                                                                when 'addressonly,' then COALESCE(@list+char(13)+char(13),'') + replace(coalesce(Address,''),char(13)+char(10),', ')

                                                                when 'dob' then COALESCE(@list+char(13)+char(13),'') + coalesce(convert(varchar(10),DOB,101),'')

                                                                when 'dobl' then COALESCE(@list+char(13)+char(13),'') + datename(month,dateadd(dd,datediff(dd,0,DOB),0)) + ' ' + cast(datepart(day,dateadd(dd,datediff(dd,0,DOB),0)) as varchar(2)) + ', ' + cast(datepart(year,dateadd(dd,datediff(dd,0,DOB),0)) as char(4))

                                                end

                                FROM @CINA_List_Distinct

                END

                RETURN @list

END

go


David Young


Viewing all articles
Browse latest Browse all 4054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>