Showing posts with label manually. Show all posts
Showing posts with label manually. Show all posts

Sunday, March 25, 2012

Cleaning up merge metadata manually is not working

Hi all,

I'm trying delete metadata of a sql 2005 sp1 subscriber from a sql 2005 sp1 merge publication, but is not working, the "retention" parameter for the publication is 999 and this is the code I'm using:

declare @.num_genhistory_rows int,

@.num_contents_rows int,

@.num_tombstone_rows int

declare @.retcode smallint

--select count(*) from msmerge_contents

-- records before 2,633,848

exec @.retcode = sys.sp_mergemetadataretentioncleanup @.num_genhistory_rows OUTPUT , @.num_contents_rows OUTPUT , @.num_tombstone_rows OUTPUT

select retcode =@.retcode

select num_genhistory_rows =@.num_genhistory_rows

select num_contents_rows=@.num_contents_rows

select num_tombstone_rows=@.num_tombstone_rows

--select count(*) from msmerge_contents

-- records after 2,633,8

Results :

retcode

0

num_genhistory_rows

0

num_contents_rows

0

num_tombstone_rows

0

Has omebody any idea why this is not working ?

I did check "sp_mergemetadataretentioncleanup " and I note that is using a function to calculate the limit date, but I could not testing because it give me the below error :

declare @.curdate datetime, @.cutoffdate datetime

select @.curdate = getdate()

select @.cutoffdate = null

-- find max retention of all pubs the article belongs to.

-- add some safety margin to compensate for different clock speeds

select @.cutoffdate = min(sys.fn_subtract_units_from_date(isnull(retention,0), retention_period_unit, @.curdate))

from dbo.sysmergepublications where

pubid in (select pubid from dbo.sysmergearticles where nickname = 5088000)

select @.cutoffdate

and this is the message error:

Msg 4121, Level 16, State 1, Line 7

Cannot find either column "sys" or the user-defined function or aggregate "sys.fn_subtract_units_from_date", or the name is ambiguous.

I looked this function but I didn't find it.

any help will be appreciated !

Firstly, if your retention is 999 days, it means that only metadata that is 1000 days old will be cleaned up (automatically or manually). So do you have data that old in the first place?

If you want to cleanup metadata, set the retention to a lower value and you will start seeing the metadata getting cleaned up automatically when merge anget runs.

The sys.xxx functions are internal functions that reside in the system resource and hence cannot be called explictly by a user.

|||

Thanks for your response Mahesh,

Here is the complete story about 999

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1148225&SiteID=1

I suspect that if I change the "retention" parameter the subscriptions will expire, is this possible with sql 2005 SP1 ?

|||

the retention cleanup will take time on the first call because it will need to do some real cleanup.

However after this, every time merge agent runs, this proc will be called. But the delta to cleanup will be very less so it should not take that long, unless of course your data load everyday is very huge.

So now if you set it to 999, and not enough metadata is genenrated, you will not see anything/or see less metadata cleaned up.

sqlsql

Thursday, March 8, 2012

CHEKING SQL AGENT IN A LAN

Hi we have a LAN of 400 stations and sometimes the agent stop in several
machines, causing jobs not to run, so i have to check manually if the agent
is running. The question is: There's a fast way to check if all the agents in
my network are started?
* my version is sql server2000 with SP4
Thanks
Have a look at "Mutiserver Adminstration" in BOL.
"amejiae" wrote:

> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the agent
> is running. The question is: There's a fast way to check if all the agents in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks
|||You might benefit greatly from a product available at:
http://www.sqlsentry.net/
Andrew J. Kelly SQL MVP
"amejiae" <amejiae@.discussions.microsoft.com> wrote in message
news:3B73EBF5-D28D-4DCA-9672-35BD27BA26B9@.microsoft.com...
> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the
> agent
> is running. The question is: There's a fast way to check if all the agents
> in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks
|||you could write a script swith SQLDMO
"amejiae" <amejiae@.discussions.microsoft.com> wrote in message
news:3B73EBF5-D28D-4DCA-9672-35BD27BA26B9@.microsoft.com...
> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the
> agent
> is running. The question is: There's a fast way to check if all the agents
> in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks
|||Or you can take a look at IDERA's Diagnostic Manager.
"amejiae" wrote:

> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the agent
> is running. The question is: There's a fast way to check if all the agents in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks

CHEKING SQL AGENT IN A LAN

Hi we have a LAN of 400 stations and sometimes the agent stop in several
machines, causing jobs not to run, so i have to check manually if the agent
is running. The question is: There's a fast way to check if all the agents i
n
my network are started?
* my version is sql server2000 with SP4
ThanksHave a look at "Mutiserver Adminstration" in BOL.
"amejiae" wrote:

> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the agen
t
> is running. The question is: There's a fast way to check if all the agents
in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks|||You might benefit greatly from a product available at:
http://www.sqlsentry.net/
Andrew J. Kelly SQL MVP
"amejiae" <amejiae@.discussions.microsoft.com> wrote in message
news:3B73EBF5-D28D-4DCA-9672-35BD27BA26B9@.microsoft.com...
> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the
> agent
> is running. The question is: There's a fast way to check if all the agents
> in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks|||you could write a script swith SQLDMO
"amejiae" <amejiae@.discussions.microsoft.com> wrote in message
news:3B73EBF5-D28D-4DCA-9672-35BD27BA26B9@.microsoft.com...
> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the
> agent
> is running. The question is: There's a fast way to check if all the agents
> in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks|||Or you can take a look at IDERA's Diagnostic Manager.
"amejiae" wrote:

> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the agen
t
> is running. The question is: There's a fast way to check if all the agents
in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks

CHEKING SQL AGENT IN A LAN

Hi we have a LAN of 400 stations and sometimes the agent stop in several
machines, causing jobs not to run, so i have to check manually if the agent
is running. The question is: There's a fast way to check if all the agents in
my network are started?
* my version is sql server2000 with SP4
ThanksHave a look at "Mutiserver Adminstration" in BOL.
"amejiae" wrote:
> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the agent
> is running. The question is: There's a fast way to check if all the agents in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks|||You might benefit greatly from a product available at:
http://www.sqlsentry.net/
Andrew J. Kelly SQL MVP
"amejiae" <amejiae@.discussions.microsoft.com> wrote in message
news:3B73EBF5-D28D-4DCA-9672-35BD27BA26B9@.microsoft.com...
> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the
> agent
> is running. The question is: There's a fast way to check if all the agents
> in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks|||you could write a script swith SQLDMO
"amejiae" <amejiae@.discussions.microsoft.com> wrote in message
news:3B73EBF5-D28D-4DCA-9672-35BD27BA26B9@.microsoft.com...
> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the
> agent
> is running. The question is: There's a fast way to check if all the agents
> in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks|||Or you can take a look at IDERA's Diagnostic Manager.
"amejiae" wrote:
> Hi we have a LAN of 400 stations and sometimes the agent stop in several
> machines, causing jobs not to run, so i have to check manually if the agent
> is running. The question is: There's a fast way to check if all the agents in
> my network are started?
> * my version is sql server2000 with SP4
> Thanks

Thursday, February 16, 2012

Checking for existence of a table that is already full-text indexe

Full-text indexing was manually set up to work on the development server.
Now, I need to write a SQL script to programmatically set up Full-text
indexing on the staging server and then on the production server.
The SQL script must be rerunnable. It should handle the scenario where
full-text indexing already exists or not, per table, as necessary.
The SQL script works on the first pass successfully (because the staging
server did not have full-text indexing).
EXEC sp_fulltext_table 'tablename', 'create', 'Catalog', 'PK_tablename'
GO
The SQL script fails on the second pass on the staging server. Because it
tries to create the index that already exists.
So, I added a statement to drop the index before creating the index.
EXEC sp_fulltext_table 'tablename', 'drop'
GO
EXEC sp_fulltext_table 'tablename', 'create', 'Catalog', 'PK_tablename'
GO
That works because it drops an existing index, then creates the index.
However, the drop statement will fail if an index doesn't exist.
So then, how do I check for the existence of a table index before dropping it?
IF EXISTS ("statement to check for existence of a table index")
BEGIN
EXEC sp_fulltext_table 'tablename', 'drop'
GO
END
EXEC sp_fulltext_table 'tablename', 'create', 'Catalog', 'PK_tablename'
GO
I looked at sp_help_fulltext_tables, but it doesn't return TRUE/FALSE that I
could use in the if statement.
EXEC sp_help_fulltext_tables 'Catalog', 'tablename'
GO
Any suggestions?
MGBloomfield,
Yes, there are some good T-SQL code examples can be found & modified for
your purposes in the procedures in KB article: 240867 (Q240867) "INF: How to
Move, Copy, and Backup Full-Text Catalog Folders and Files" at:
http://support.microsoft.com/default...b;EN-US;240867
You might also find this code useful as well:
-- To Create/Remove the Existing Full-Text Table Index, Catalog
-- If Full-Text Index exists, DROP that Index,
-- If Full-Text Index does not exist, CREATE that Index.
use pubs
go
IF OBJECTPROPERTY ( object_id('pub_info'),'TableHasActiveFulltextIndex ') = 1
BEGIN
print 'Table pub_info is Full-Text Enabled, dropping Full-Text Index &
Catalog...'
EXEC sp_fulltext_table 'pub_info', 'drop'
EXEC sp_fulltext_catalog 'PubInfo', 'drop'
END
ELSE IF OBJECTPROPERTY (
object_id('pub_info'),'TableHasActiveFulltextIndex ') = 0
BEGIN
print 'Table pub_info is NOT Full-Text Enabled, creating FT Catalog,
Index & Activating...'
EXEC sp_fulltext_catalog 'PubInfo', 'create'
EXEC sp_fulltext_table 'pub_info', 'create', 'PubInfo', 'UPKCL_pubinfo'
EXEC sp_fulltext_column 'pub_info', 'pub_id', 'add'
EXEC sp_fulltext_column 'pub_info', 'pr_info', 'add'
EXEC sp_fulltext_table 'pub_info', 'activate'
END
Regards,
John
"MGBloomfield" <MGBloomfield@.discussions.microsoft.com> wrote in message
news:F80D1509-E8EF-4B4F-9011-BA44DF7EF91C@.microsoft.com...
> Full-text indexing was manually set up to work on the development server.
> Now, I need to write a SQL script to programmatically set up Full-text
> indexing on the staging server and then on the production server.
> The SQL script must be rerunnable. It should handle the scenario where
> full-text indexing already exists or not, per table, as necessary.
> The SQL script works on the first pass successfully (because the staging
> server did not have full-text indexing).
> EXEC sp_fulltext_table 'tablename', 'create', 'Catalog', 'PK_tablename'
> GO
> The SQL script fails on the second pass on the staging server. Because it
> tries to create the index that already exists.
> So, I added a statement to drop the index before creating the index.
> EXEC sp_fulltext_table 'tablename', 'drop'
> GO
> EXEC sp_fulltext_table 'tablename', 'create', 'Catalog', 'PK_tablename'
> GO
> That works because it drops an existing index, then creates the index.
> However, the drop statement will fail if an index doesn't exist.
> So then, how do I check for the existence of a table index before dropping
it?
> IF EXISTS ("statement to check for existence of a table index")
> BEGIN
> EXEC sp_fulltext_table 'tablename', 'drop'
> GO
> END
> EXEC sp_fulltext_table 'tablename', 'create', 'Catalog', 'PK_tablename'
> GO
> I looked at sp_help_fulltext_tables, but it doesn't return TRUE/FALSE that
I
> could use in the if statement.
> EXEC sp_help_fulltext_tables 'Catalog', 'tablename'
> GO
> Any suggestions?
>