Sunday, March 11, 2012

Change Unique ID to non unique ID in replicated table

Hi,
I have a replicated to table. It has the ID column as unique and I want it
to convert it into non unique. How can I do it?
Exactly what do you mean by non-unique. There are three kinds of indexes,
clustered, non clustered or unique.
Unique means an index or actually a constraint that uses an index, which
ensures unique values and allows a null. A non-clustered index is an index
that is maintained on a seperate database page containing pointers which
point back to where in the table a particular value occurs. A clustered
index orders the data in the table according to a criteria.
To change an index you do this
sp_help tablename and obtain the index name
then drop the index
drop index authors.aunmind
then recreate it (if you want to convert the index to a clustered or
non-clustered index).
I assume you are talking about the table on the subscriber.
If you want to replicate a primary key which occurs on a published table on
the publisher to a primary key on the subscriber right click on yoru
publication, select properties, click the articles tab, and click the three
ellipses next to your article you wish to modify the index on. Then in the
snapshot tab, check include DRI. By default primary keys are replicated as
unique indexes on the subscriber.
HTH
Hilary Cotter
Looking for a book on SQL Server replication?
http://www.nwsu.com/0974973602.html
"Vivek" <vivek@.nospam.com> wrote in message
news:uMeeotwjEHA.2908@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I have a replicated to table. It has the ID column as unique and I want
it
> to convert it into non unique. How can I do it?
>
|||Hi Hillary,
Thanks for your reply. I think I should have framed my query differently.
I have a table on publisher with a primary key. What we intend to do is get
rid of the primary key so that we can insert any number and the following
records. Now, how do I can I change the column to be not primary key.
Thanks
Vivek
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:%23Dv3VS1jEHA.1520@.TK2MSFTNGP10.phx.gbl...
> Exactly what do you mean by non-unique. There are three kinds of indexes,
> clustered, non clustered or unique.
> Unique means an index or actually a constraint that uses an index, which
> ensures unique values and allows a null. A non-clustered index is an index
> that is maintained on a seperate database page containing pointers which
> point back to where in the table a particular value occurs. A clustered
> index orders the data in the table according to a criteria.
> To change an index you do this
> sp_help tablename and obtain the index name
> then drop the index
> drop index authors.aunmind
> then recreate it (if you want to convert the index to a clustered or
> non-clustered index).
> I assume you are talking about the table on the subscriber.
> If you want to replicate a primary key which occurs on a published table
on
> the publisher to a primary key on the subscriber right click on yoru
> publication, select properties, click the articles tab, and click the
three
> ellipses next to your article you wish to modify the index on. Then in the
> snapshot tab, check include DRI. By default primary keys are replicated as
> unique indexes on the subscriber.
> HTH
> --
> Hilary Cotter
> Looking for a book on SQL Server replication?
> http://www.nwsu.com/0974973602.html
>
> "Vivek" <vivek@.nospam.com> wrote in message
> news:uMeeotwjEHA.2908@.TK2MSFTNGP10.phx.gbl...
> it
>
|||You will have to alter the table to drop the constraint
create table primarykey
(pk int not null identity(1,1) primary key)
GO
sp_help primarykey
GO
--scroll down until you see the name of the primary key - in our case its
called PK__primarykey__52AE4273
alter table primarykey
drop constraint PK__primarykey__52AE4273
GO
Hilary Cotter
Looking for a book on SQL Server replication?
http://www.nwsu.com/0974973602.html
"Vivek Sharma" <joebloggs@.news.com> wrote in message
news:OV7xLN9jEHA.2412@.TK2MSFTNGP15.phx.gbl...
> Hi Hillary,
> Thanks for your reply. I think I should have framed my query differently.
> I have a table on publisher with a primary key. What we intend to do is
get[vbcol=seagreen]
> rid of the primary key so that we can insert any number and the following
> records. Now, how do I can I change the column to be not primary key.
> Thanks
> Vivek
>
> "Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
> news:%23Dv3VS1jEHA.1520@.TK2MSFTNGP10.phx.gbl...
indexes,[vbcol=seagreen]
index[vbcol=seagreen]
> on
> three
the[vbcol=seagreen]
as[vbcol=seagreen]
want
>
|||Thanks a lot Hilary. It was a great help.
Vivek
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:elqZKECkEHA.384@.TK2MSFTNGP10.phx.gbl...[vbcol=seagreen]
> You will have to alter the table to drop the constraint
> create table primarykey
> (pk int not null identity(1,1) primary key)
> GO
> sp_help primarykey
> GO
> --scroll down until you see the name of the primary key - in our case its
> called PK__primarykey__52AE4273
> alter table primarykey
> drop constraint PK__primarykey__52AE4273
> GO
> --
> Hilary Cotter
> Looking for a book on SQL Server replication?
> http://www.nwsu.com/0974973602.html
>
> "Vivek Sharma" <joebloggs@.news.com> wrote in message
> news:OV7xLN9jEHA.2412@.TK2MSFTNGP15.phx.gbl...
differently.[vbcol=seagreen]
> get
following[vbcol=seagreen]
> indexes,
which[vbcol=seagreen]
> index
which[vbcol=seagreen]
clustered[vbcol=seagreen]
table[vbcol=seagreen]
> the
replicated
> as
> want
>

No comments:

Post a Comment