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.
| Author |
Topic |
|
borowik80
Starting Member
4 Posts |
Posted - 2012-09-10 : 02:40:48
|
| Hi,I've got table with the following fields:Cube_Id|Cube_RT|CubeName|Project_IdCube_Id is the PKProject_Id is the FKCube_ST,CubeName and Project_Id are not unique.while inserting and updating data I need to check if combination Cube_RT and Project_Id already exists in the table. If so, then constraint must prevent updating table because this combination has to be unique.How can I achive that?Regards,Luk |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-09-10 : 06:50:17
|
| If I am reading your requirement correctly, adding a unique constraint on Cube_RT and Project_ID should achieve what you are looking for. http://msdn.microsoft.com/en-us/library/ms177420(v=sql.105).aspxBut, what gives me pause is that you said Cube_ST, CubeName and Project_ID are not unique. Is Cube_ST another column in the table? If so, how does Cube_RT + Project_ID being unique impact that? |
 |
|
|
borowik80
Starting Member
4 Posts |
Posted - 2012-09-30 : 07:07:45
|
| Thanks sunitabeck this is what I was looking for. |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-09-30 : 18:45:02
|
| You are quite welcome :) |
 |
|
|
|
|
|