SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 constraint problem
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sunsanvin
Flowing Fount of Yak Knowledge

India
1274 Posts

Posted - 05/14/2007 :  03:05:02  Show Profile  Send sunsanvin a Yahoo! Message  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
1274 Posts

Posted - 05/14/2007 :  04:36:52  Show Profile  Send sunsanvin a Yahoo! Message  Reply with Quote
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 - 05/14/2007 :  04:43:54  Show Profile  Reply with Quote
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

United Kingdom
22415 Posts

Posted - 05/14/2007 :  05:11:01  Show Profile  Reply with Quote
"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
Flowing Fount of Yak Knowledge

India
1274 Posts

Posted - 05/15/2007 :  02:22:03  Show Profile  Send sunsanvin a Yahoo! Message  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
1274 Posts

Posted - 05/15/2007 :  05:09:02  Show Profile  Send sunsanvin a Yahoo! Message  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000