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
 General SQL Server Forums
 New to SQL Server Programming
 constraint problem

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-05-14 : 03:05:02
Dear Folks,
I've two tables,(table014,table015)
column01 of table014 is a primary key, and column04 is the foriegnkey.
column02 of table015 is also foriegn key.

how can i update column01 of table014?

actually I've done this through enterprise manager, by disabling the enforcement of constraints.

how can i do this by using query? and what is the correct way of doing this?


thank you verymuch


Vinod
Even you learn 1%, Learn it with 100% confidence.

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-05-14 : 04:36:52
Friends,
I"m sorry, if i didn't provide proper information for you.

the column01 of table014 is a primary key , column004 of table014 and column02 of table015 are the foriegn keys. please tell me the correct way how can i update column01 of table014?

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2007-05-14 : 04:43:54
You should not update primary keys. Arguably immutability is one of the primary things about them.
You should

begin transaction
add a dummy row to table014 with your new PK
update column 2 of 15 to new PK
update column 4 of 14 to new PK
delete using original PK from 14
commit.

And then go through your data model and fix it up so it has proper primary keys and proper table/column names.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-05-14 : 05:11:01
"table014 table015"

Scary table names ...

... Table1 and Table2 I could have believed were "example names", 014 and 015 don't sound like examples though ...

Kristen
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-05-15 : 02:22:03
no no kiristen there are code names for our team, for each module, the suffix and prefix will change. we are very clear with this

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-05-15 : 05:09:02
quote:
Originally posted by LoztInSpace

You should not update primary keys. Arguably immutability is one of the primary things about them.
You should

begin transaction
add a dummy row to table014 with your new PK
update column 2 of 15 to new PK
update column 4 of 14 to new PK
delete using original PK from 14
commit.

And then go through your data model and fix it up so it has proper primary keys and proper table/column names.





I didn't get you. how can i take another primary key?

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page
   

- Advertisement -