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
 Custom check
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

borowik80
Starting Member

4 Posts

Posted - 09/10/2012 :  02:40:48  Show Profile  Reply with Quote
Hi,

I've got table with the following fields:

Cube_Id|Cube_RT|CubeName|Project_Id

Cube_Id is the PK
Project_Id is the FK

Cube_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
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 09/10/2012 :  06:50:17  Show Profile  Reply with Quote
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).aspx

But, 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?
Go to Top of Page

borowik80
Starting Member

4 Posts

Posted - 09/30/2012 :  07:07:45  Show Profile  Reply with Quote
Thanks sunitabeck this is what I was looking for.
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 09/30/2012 :  18:45:02  Show Profile  Reply with Quote
You are quite welcome :)
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.07 seconds. Powered By: Snitz Forums 2000