Friday, March 23, 2012

How to change IDENTITY to NOT FOR REPLICATION?

I need to change many IDENTITY columns in many tables so that they show as
NOT FOR REPLICATION. This way when I replicate, it doesn't trash my identity
values. I can do it with Enterprise Manager without any problems but I need
to code it (using t-sql) so I can repeat the process and undo it later.
I have not been able to come up with a suitable syntax.
How can I use ALTER TABLE/ALTER COLUMN to change a col from IDENTITY to
IDENTITY NOT FOR REPLICATION? I don't want to drop the column and recreate
it!
Any help appreciated.
Thanks in regards,
JessYou will have to drop and recreate the table if you want the same column in
the same ordinal position.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com
.
"languy" <jn@.online.stofanet.dk> wrote in message
news:OddrwY2DFHA.624@.TK2MSFTNGP09.phx.gbl...
I need to change many IDENTITY columns in many tables so that they show as
NOT FOR REPLICATION. This way when I replicate, it doesn't trash my identity
values. I can do it with Enterprise Manager without any problems but I need
to code it (using t-sql) so I can repeat the process and undo it later.
I have not been able to come up with a suitable syntax.
How can I use ALTER TABLE/ALTER COLUMN to change a col from IDENTITY to
IDENTITY NOT FOR REPLICATION? I don't want to drop the column and recreate
it!
Any help appreciated.
Thanks in regards,
Jess

No comments:

Post a Comment