|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Wednesday, April 24, 2013 11:19 AM
Points: 309,
Visits: 645
|
|
Following is the empdetails table in my organization which has been used for last 3 years.
create table Empdetails(empid int , empname varchar)
We noticed that there was no primary key and now we are looking for transactional replication to replicate this data. How can I create primary key on this table. According to my understanding the primary key can be created only when the table is created. Do I need to create a dummy table and then transferring data, rename this table as Empdetails after dropping the original table?
-Lk
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 4:49 AM
Points: 1,075,
Visits: 5,119
|
|
luckysql.kinda (2/16/2010) Following is the empdetails table in my organization which has been used for last 3 years.
create table Empdetails(empid int , empname varchar)
We noticed that there was no primary key and now we are looking for transactional replication to replicate this data. How can I create primary key on this table. According to my understanding the primary key can be created only when the table is created. Do I need to create a dummy table and then transferring data, rename this table as Empdetails after dropping the original table?
-Lk ALTER TABLE Empdetails ADD CONSTRAINT PK_Empdetails PRIMARY KEY .... Refer BOL for more information.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 3:12 PM
Points: 2,988,
Visits: 4,409
|
|
Check if you have an unique index on empid column...
if yes then build your PK on it. if no then check for and fix empid duplicates then build your PK on it.
_____________________________________ Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
|
|
|
|