Sunday, March 11, 2012

ALTER PK

As I'm in the process of planning replication of two
tables to from one database in one location (country) to
another location (another country) I need to change the
tables using an ALTER TABLE statement so that the UNIQUE
index acting as the primary key, changed to a declared
primary key.
Since I will be applying this change to a live production
environment will there be any issues when applying this
change.
The key column is defined currently as:
data type: uniqueidentifier
allow nulls: no
default value: newid()
Thanks,
AnjelinaAnjelina
I don't see any negative issues if you are going to apply this change. If a
table is large then it will take time to arrange keys with ascending order.
BOL says:
"Creating a PRIMARY KEY or UNIQUE constraint automatically creates a unique
index on the specified columns in the "table
"anjelina" <ajturner@.canada.com> wrote in message
news:078701c38e21$cd144af0$a401280a@.phx.gbl...
> As I'm in the process of planning replication of two
> tables to from one database in one location (country) to
> another location (another country) I need to change the
> tables using an ALTER TABLE statement so that the UNIQUE
> index acting as the primary key, changed to a declared
> primary key.
> Since I will be applying this change to a live production
> environment will there be any issues when applying this
> change.
> The key column is defined currently as:
> data type: uniqueidentifier
> allow nulls: no
> default value: newid()
> Thanks,
> Anjelina
>|||If the primary key constraint will be a clustered index, all of the
non-clustered indexes will automatically be re-built. This can take some
time on a large table, and users will not be able to access the table
during this time.
Kick everyone off of the system prior to beginning.
drop the unique constraint.
then create the primary key constraint.
When complete, be sure to back up the database with a full or differential
backup.
--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"anjelina" <ajturner@.canada.com> wrote in message
news:078701c38e21$cd144af0$a401280a@.phx.gbl...
> As I'm in the process of planning replication of two
> tables to from one database in one location (country) to
> another location (another country) I need to change the
> tables using an ALTER TABLE statement so that the UNIQUE
> index acting as the primary key, changed to a declared
> primary key.
> Since I will be applying this change to a live production
> environment will there be any issues when applying this
> change.
> The key column is defined currently as:
> data type: uniqueidentifier
> allow nulls: no
> default value: newid()
> Thanks,
> Anjelina
>

No comments:

Post a Comment