Click here to Skip to main content
15,917,859 members
Home / Discussions / Database
   

Database

 
QuestionUsing DatePart as part of a Unique Constraint? Pin
kbalias12-Mar-08 1:07
kbalias12-Mar-08 1:07 
Hi
We are using SQL Server 2005. In a table we want to add a Unique constraint to ensure that only one record can be added for a student per day. The two columns for the constraint will be StudentIndex and IssueDate. We cannot use the whole IssueDate value because of the hour, min, seconds, milliseconds parts. Is it possible to use DateParts as part of a Unique constraint?

The following does not work:
CONSTRAINT UQ_Issues
UNIQUE ( DATEPART(dd, IssueDate), DATEPART(mm, IssueDate), DATEPART(yy, IssueDate), StudentIndex )


Any ideas will be appreciated.

Thanks

Kobus
AnswerRe: Using DatePart as part of a Unique Constraint? Pin
Syed Mehroz Alam12-Mar-08 1:48
Syed Mehroz Alam12-Mar-08 1:48 
QuestionMembership Stored Procedures Confusion Pin
Brendan Vogt11-Mar-08 22:59
Brendan Vogt11-Mar-08 22:59 
GeneralRe: Membership Stored Procedures Confusion Pin
Mark J. Miller13-Mar-08 5:48
Mark J. Miller13-Mar-08 5:48 
QuestionRunning SQL Server stored procedure Pin
ambrose11-Mar-08 22:56
ambrose11-Mar-08 22:56 
GeneralRe: Running SQL Server stored procedure Pin
Mark J. Miller13-Mar-08 5:56
Mark J. Miller13-Mar-08 5:56 
GeneralConcurrency violation Pin
baranils11-Mar-08 21:31
baranils11-Mar-08 21:31 
GeneralRe: Concurrency violation Pin
Mark J. Miller13-Mar-08 6:01
Mark J. Miller13-Mar-08 6:01 
GeneralRe: Concurrency violation Pin
baranils13-Mar-08 6:54
baranils13-Mar-08 6:54 
Generalsql structure Pin
Tara1411-Mar-08 21:02
Tara1411-Mar-08 21:02 
GeneralRe: sql structure Pin
andyharman12-Mar-08 0:08
professionalandyharman12-Mar-08 0:08 
GeneralRe: sql structure Pin
Tara1412-Mar-08 7:45
Tara1412-Mar-08 7:45 
GeneralRe: sql structure Pin
Syed Mehroz Alam12-Mar-08 0:17
Syed Mehroz Alam12-Mar-08 0:17 
GeneralRe: sql structure Pin
Tara1412-Mar-08 5:50
Tara1412-Mar-08 5:50 
GeneralRe: sql structure Pin
Tara1412-Mar-08 7:36
Tara1412-Mar-08 7:36 
GeneralPassword Expiry Pin
manowj11-Mar-08 20:24
manowj11-Mar-08 20:24 
GeneralCannot resolve collation conflict for equal to operation. Pin
AlexeiXX311-Mar-08 14:44
AlexeiXX311-Mar-08 14:44 
GeneralRe: Cannot resolve collation conflict for equal to operation. Pin
AlexeiXX311-Mar-08 15:17
AlexeiXX311-Mar-08 15:17 
QuestionProblems Exporting From DataSet to .DBF File Pin
Snaider11-Mar-08 9:00
Snaider11-Mar-08 9:00 
GeneralRe: Problems Exporting From DataSet to .DBF File Pin
perryf_0011-Mar-08 12:12
perryf_0011-Mar-08 12:12 
GeneralRe: Problems Exporting From DataSet to .DBF File Pin
Snaider12-Mar-08 0:18
Snaider12-Mar-08 0:18 
GeneralDataRelation and NOCHECK add constraint Pin
CJacobus11-Mar-08 6:21
CJacobus11-Mar-08 6:21 
GeneralRe: DataRelation and NOCHECK add constraint Pin
Mark J. Miller11-Mar-08 7:28
Mark J. Miller11-Mar-08 7:28 
GeneralRe: DataRelation and NOCHECK add constraint Pin
CJacobus12-Mar-08 11:15
CJacobus12-Mar-08 11:15 
GeneralRe: DataRelation and NOCHECK add constraint Pin
Mark J. Miller13-Mar-08 3:29
Mark J. Miller13-Mar-08 3:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.