all groups > sql server replication > october 2005 >
You're in the

sql server replication

group:

Alter table


Re: Alter table Paul Ibison
10/6/2005 12:00:00 AM
sql server replication:
Darin,
I'd probably use something like this:

declare @mytablename varchar(100)
set @mytablename = 'testtr'
if exists(SELECT name FROM sysarticles where name =
@mytablename)
or exists(SELECT name FROM sysarticles where name =
@mytablename)
select 'exists'

Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

Re: Alter table Paul Ibison
10/6/2005 12:00:00 AM
Sorry - second one is for merge...
Actually it lacked a bit more code which I've added. There are 2 versions
and the second one would be more elegant (you'll need to test it).
Cheers,
Paul Ibison

declare @mytablename varchar(100)
set @mytablename = 'testtr'

if (select object_id('sysarticles')) is not null
begin
if exists (SELECT name FROM sysarticles where name =
@mytablename)
select 'yes'
end
if (select object_id('sysmergearticles')) is not null
begin
if exists(SELECT name FROM sysmergearticles where name =
@mytablename)
select 'yes'
end

if (select replinfo from sysobjects where name = @mytablename) > 0
select 'yes'

Alter table Darin
10/6/2005 5:48:52 AM
I know I can't do an alter table on a replicated table because it is
being replicated. But, in my software, if I need to modify a table I do
an alter table and add the new column.

What is the easy way, via SQL script, to see if this machine is a
distributor/publisher for replication, in which case I need to do the
sp_repladdcolumn, or a subscriber, in which case I need to do nothing
because the dist/pub will do it, or neither, in which case I need to do
the alter table?

Thanks.

Darin

Re: Alter table Darin
10/6/2005 6:33:46 AM
Did you mean for both of the select statements to be the same?

Darin

AddThis Social Bookmark Button