Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Avoid duplicates in 2 columns
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

StephenD
Senior Member

Australia
1044 Posts

Posted - 01 April 2007 :  21:59:47  Show Profile  Send StephenD a Yahoo! Message
Looks like my brain is on holiday this morning ...

How do I prevent duplicate records in a table in two of my columns?

table structure:

CREATE TABLE [dbo].[FORUM_CERTIFICATES] (
	[TOPIC_ID] [int] NOT NULL ,
	[ExpDate] [nvarchar] (14) COLLATE Latin1_General_CI_AS NULL ,
	[IssueDate] [nvarchar] (14) COLLATE Latin1_General_CI_AS NULL ,
	[CERT_ID] [int] NOT NULL 
) ON [PRIMARY]
GO


Both CERT_ID and TOPIC_ID cannot have duplicate records. I will be using CERT_ID for searching on later.

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 02 April 2007 :  04:31:14  Show Profile  Send ruirib a Yahoo! Message
You should have a primary key. Probably CERT_ID is the likely. For the other column use a UNIQUE restriction:

CREATE TABLE [dbo].[FORUM_CERTIFICATES] (
	[TOPIC_ID] [int] UNIQUE NOT NULL ,
	[ExpDate] [nvarchar] (14) COLLATE Latin1_General_CI_AS NULL ,
	[IssueDate] [nvarchar] (14) COLLATE Latin1_General_CI_AS NULL ,
	[CERT_ID] [int] PRIMARY KEY NOT NULL 
) ON [PRIMARY]
GO




Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

StephenD
Senior Member

Australia
1044 Posts

Posted - 02 April 2007 :  04:55:27  Show Profile  Send StephenD a Yahoo! Message
Ah thanks Rui!
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 02 April 2007 :  05:06:10  Show Profile  Send ruirib a Yahoo! Message
You're welcome.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.18 seconds. Powered By: Snitz Forums 2000 Version 3.4.07