Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Tables without primary keys

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-03-29 : 08:45:13
Chander writes "Hi,
I'm new to sql server and working on a project with quite tight deadline.
I'm configuring the transactional replication and realised in the middle that some of the tables are without any primary keys.
I thought of creating dublicate tables with added dummy column (for PK) with IDENTITY feature, then insert records from original table to this duplicate table, marking this dummy column as primary key and finally rename them. With this approach I can achieve the objective but the new added column could become potential risk to the application.
any advice, suggestion on this?
Is there any way in SQL Server to enforce the primary keys without changing the existing structure? Is there any option of hidden column or any other solution to this?

I cannot do the Transactional Replication unless these tables are defined with Primary Key.

Thanks & Regards
Chander Sangra"

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-03-29 : 10:22:27
>>any other solution to this?

Is there a reason you can't use a natural combination of columns to be the PK? If there is no combination of columns that would define a unique row and you aren't using a surrogoate key, then you have no way of enforcing unique-ness between rows. If your goal is transactional replication then your only option is to have a PK (either natural key based on a combination of columns or a surrogate key (like an identity column).

Be One with the Optimizer
TG
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-03-29 : 10:30:38
You should never create a table that does not have a primary key. There aren't too many rules that should never be broken, but that is one of them.

If you do, you'll regret it sooner or later.





CODO ERGO SUM
Go to Top of Page
   

- Advertisement -