|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Today @ 10:25 AM
Points: 18,754,
Visits: 12,337
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, February 06, 2013 9:31 AM
Points: 6,
Visits: 129
|
|
| Another benefit of using the built in sp_publication_validation or sp_article_validation stored procs is that if the validation fails during execution, it will raise an error to the application log. There's a built in alert for replication validation failures which can automatically reinitialize the subscriptions, or just send email notifications via Database Mail to all concerned parties, or do both.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Sunday, February 03, 2013 8:52 PM
Points: 11,
Visits: 45
|
|
The built in validation procedures (article and publication) have existed since at least SQL Server 7.0. The parameters have not changed, so the same code that worked on SQL Server 7.0 would work on every version through SQL Server 2008 R2. (I can't remember if the validation procedures existed in SQL Server 6.5, but I do know they are there from 7.0 onwards.)
Michael Hotek President - Champion Valley Software, Inc. http://www.ChampionValleySoftware.com
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, March 08, 2013 12:43 PM
Points: 33,
Visits: 257
|
|
Given some of the limitations with Replication Monitoring, problems with stale subscriptions on large tables etc it's a solid approach.
Kudos Thanh -- nice article!
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Yesterday @ 4:47 AM
Points: 636,
Visits: 384
|
|
Hi Guys,
Does anyone get a syntax issue on the below piece of code?
IF OBJECT_ID('tempdb..#tempSubscribedArticles') IS NOT NULL DROP TABLE #tempSubscribedArticles
CREATE TABLE #tempSubscribedArticles ( subscriber_srv VARCHAR(255), subscriber_db VARCHAR(255), destination_owner VARCHAR(255), destination_object VARCHAR(255), object_type VARCHAR(255), rowcount_subscriber INT )
DECLARE @sub_srv VARCHAR(255), @sub_db VARCHAR(255), @strSQL_S VARCHAR(4000)
DECLARE db_cursor_s CURSOR FOR SELECT DISTINCT subscriber_srv, subscriber_db FROM #tempTransReplication
OPEN db_cursor_s FETCH NEXT FROM db_cursor_s INTO @sub_srv, @sub_db
WHILE @@FETCH_STATUS = 0 BEGIN SET @strSQL_S = 'SELECT ' + '''' + @sub_srv + '''' + ' AS subscriber_srv, ' + '''' + @sub_db + '''' + ' AS subscriber_db, ' + 's.name AS destination_owner, o.name AS destination_object, o.Type_Desc AS object_type, i.rowcnt AS rowcount_subscriber FROM ' + @sub_srv + '.' + @sub_db + '.sys.objects AS o INNER JOIN ' + @sub_srv + '.' + @sub_db + '.sys.schemas AS s on o.schema_id = s.schema_id LEFT OUTER JOIN ' + @sub_srv + '.' + @sub_db + '.dbo.sysindexes AS i on o.object_id = i.id WHERE ' + '''' + @sub_srv + '.' + @sub_db + '''' + ' + ' + '''' + '.' + '''' + ' + s.name' + ' + ' + '''' + '.' + '''' + ' + o.name' + ' IN (SELECT subscriber_srv + ' + '''' + '.' + '''' + ' + subscriber_db + ' + '''' + '.' + '''' + ' + destination_owner + ' + '''' + '.' + '''' + ' + destination_object FROM #tempTransReplication) AND ISNULL(i.indid, 0) IN (0, 1) ORDER BY i.rowcnt DESC' -- heap (indid=0); clustered index (indix=1) INSERT INTO #tempSubscribedArticles EXEC ( @strSQL_S ) FETCH NEXT FROM db_cursor_s INTO @sub_srv, @sub_db END CLOSE db_cursor_s DEALLOCATE db_cursor_s
I get this error when I am running it.
Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '-'. Msg 156, Level 15, State 1, Line 6 Incorrect syntax near the keyword 'AND'. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '-'. Msg 156, Level 15, State 1, Line 6 Incorrect syntax near the keyword 'AND'. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '-'. Msg 156, Level 15, State 1, Line 6 Incorrect syntax near the keyword 'AND'. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '-'. Msg 156, Level 15, State 1, Line 6 Incorrect syntax near the keyword 'AND'. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '-'. Msg 156, Level 15, State 1, Line 6 Incorrect syntax near the keyword 'AND'. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '-'. Msg 156, Level 15, State 1, Line 6 Incorrect syntax near the keyword 'AND'. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '-'. Msg 156, Level 15, State 1, Line 6 Incorrect syntax near the keyword 'AND'. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '-'. Msg 156, Level 15, State 1, Line 6 Incorrect syntax near the keyword 'AND'. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '-'. Msg 156, Level 15, State 1, Line 6 Incorrect syntax near the keyword 'AND'.
Any advice will be very helpful 
|
|
|
|