|
-
Aug 10th, 2004, 08:58 AM
#1
Thread Starter
Frenzied Member
SQL Server Table ... Can I have 2nd key ?
I've got a SQL Server table(that I created using Enterprise Manager).
I've not played with this much, but I want to have a secondary key on my table, and can't find an option where to do it.
Does this mean each table can only have 1 unique key ?
Last edited by TheBionicOrange; Aug 10th, 2004 at 09:02 AM.
-
Aug 10th, 2004, 09:19 AM
#2
Select 2 columns (using control) then press the "key" symbol. Now the combination of both fields ,ust be unique
-
Aug 10th, 2004, 09:38 AM
#3
Thread Starter
Frenzied Member
I want a secondary key, not a composite key.
-
Aug 10th, 2004, 10:04 AM
#4
Fanatic Member
You can have only one Primary (unique) key per table, but you can add an Unique Index on the table that will force unique values per row for that column:
Code:
CREATE UNIQUE INDEX myIndexName
ON myTableName (myColumnName)
Chris
Master Of My Domain
Got A Question? Look Here First
-
Aug 10th, 2004, 03:54 PM
#5
UNIQUE constraints are implemented by an ALTERNATE INDEX on the table.
But they force UNIQUE values in those columns.
If you do not want that, then just CREATE alternate indexes.
Like this:
Code:
CREATE INDEX AKClaim on Claim_T (MasId,FirstDate,BeneType)
CREATE INDEX AKClaim2 on Claim_T (AdjDate,Processor,ClaimSeq)
CREATE INDEX AKClaim3 on Claim_T (PostDate,Processor,ClaimEntry)
CREATE INDEX AKClaim4 on Claim_T (ClaimEntry)
CREATE INDEX AKClaim5 on Claim_T (ReversalDate)
CREATE INDEX AKClaim6 on Claim_T (CheckNum)
-
Aug 11th, 2004, 03:29 AM
#6
New Member
TheBionicOrange, how have you created the SQL Server Table using Enterprise Manager? Need Help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|