2012年12月19日
摘要: 1、alter table testTB add constraint U_check check(birthday<=getdate())这句话就约束了出生日期必须小于等于今天,也可以在建表的时候写在最后为 check(birthday<=getdate())2、创建索引1 create unique index idx_id_birthday2 on testTB(ID,birthday) 阅读全文
posted @ 2012-12-19 16:21 yj_smile 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 今天在看资料,讲的是根据一个人的出生日期和今天的日期来计算他最近的生日。这个问题在一定程度上演示了如何通过使用datetime函数正确处理闰年。下面我会建一张测试表,来说明问题1 create table testTB2 (3 ID int primary key identity (1,1),4 name varchar(20),5 birthday datetime6 )然后插入几条数据INSERT INTO TESTTB VALUES('yj','1990-08-20')INSERT INTO TESTTB VALUES('cyf', 阅读全文
posted @ 2012-12-19 16:10 yj_smile 阅读(328) 评论(0) 推荐(0) 编辑