There is a way to create a constraint or something where I can have only one record for a Day for a FK column? I.E.
PK(IDENTITY(1,1)) FK_FIELD DATETIME
------------------------------
1 1 2012-02-22 4:50 p.m.
2 2 2012-02-23 12:00 p.m.
3 2 2012-02-23 9:00 p.m. -- This one should not be allowed because the FK_Field 2 would have 2 record in one day.
4 1 2012-02-23 08:00 a.m
Hopefully someone understand what im trying to archieve.
Thanks in advance.
Consider using:
Some examples of a variety of persisted columns (Much thanks to Aaron Bertrand):
N.B. These examples were chosen carefully to ensure function determinism.
Here’s a sample SQL:
If you attempted the INSERTs, this is what you get:
The message shown in SQL Server Management Studio is: