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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 I should know this

Author  Topic 

SamC
White Water Yakist

3467 Posts

Posted - 2003-09-30 : 11:34:01
I've heard a rumor that sqlteam possesses powers to give answers as the question is typed. Let's see.

I've got a table 'Users" which holds Email, ClientID. I had assumed the column Email would be UNIQUE but I can see a light ahead and I don't think it's the end of the tunnel (if you know what I mean).

Turns out some users are actually contractors which *may* actually contract to more than 1 of my Clients. This puts me in a position of allowing a user row to exist for two clients with the same email address.

Wait! I have the answer! Sort of. But I don't know the syntax..

I need to direct the table to make ClientID, Email UNIQUE not just Email.

Howdayadothat?

CREATE TABLE MyTable (
ClintID INT NOT NULL ,
Email VARCHAR (100) NOT NULL
)

Thank you SQLTEAM.

Sam

nr
SQLTeam MVY

12543 Posts

Posted - 2003-09-30 : 11:41:43
create unique index ix_MyTable _01 on MyTable (ClientID, Email)

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2003-09-30 : 12:15:08
Thanks Nigel..

Have a warm on me.

Go to Top of Page
   

- Advertisement -