Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an existing table 'AccountMappingMaster'
with already 4 primary key
and now I just want to add a new column as primary key also without losing my data.

I've tried Drop and Create but If I have to do it, I have to use Insert to recover my data. But I have a lot of data and it would take time to make it done.

please someone help me. Thanks
Posted

1 solution

Try the following
1) drop the constraint on the table
2) add the column
3) add data in this column
4) make a new primary key with the 5 fields

To get a list of constraints on the table, try
SQL
select OBJECT_NAME(OBJECT_ID) AS constrnt
FROM sys.objects
where OBJECT_NAME(parent_object_id)='AccountMappingMaster'
and type_desc LIKE '%CONSTRAINT'
 
Share this answer
 
Comments
qwerzxcxyz 21-Sep-15 23:46pm    
I've try this and it works, thanks a lot
aarif moh shaikh 22-Sep-15 0:31am    
good one... 5
Abhinav S 22-Sep-15 1:42am    
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900