日期:2014-05-16 浏览次数:20517 次
USE tempdb
IF OBJECT_ID('TEST') IS NOT NULL
DROP TABLE TEST; --> 如果表TEST不为空,删除表
GO
CREATE TABLE TEST --> 创建表,字段及类型如下
(
UID varchar(20), --> 编号
sDate datetime, --> 日期字段
sTime datetime, --> 时间字段
MacID int, --> 机器号
jiange int --> 这是机器要求的时间间隔字段,单位分钟
);
GO
INSERT TEST --> 向表中插入数据
select '0076','2013-08-11 00:00:00','2013-08-11 21:54:01',1,15 union all
select '0076','2013-09-07 00:00:00','2013-09-07 11:00:01',1,15 union all
select '0076','2013-09-07 00:00:00','2013-09-07 17:20:01',1,15 union all
select '0076','2013-09-07 00:00:00','2013-09-07 17:21:01',1,15 union all
select '0076','2013-09-08 00:00:00','2013-09-08 23:36:01',2,20 union all
select '0076','2013-09-11 00:00:00','2013-09-11 16:57:01',2,20 union all
select '0076','2013-09-15 00:00:00','2013-09-15 10:31:01',1,15 union all
select '0076','2013-09-15 00:00:00','2013-09-15 10:32:01',1,15 union all
select '0076','2013-09-21 00:00:00','2013-09-21 05:56:01',2,20 union all
select '0076','2013-09-21 00:00:00','2013-09-21 05:57:01',2,20 union all
select '0076','2013-09-21 00:00:00','2013-09-21 05:57:01',2,20 union all
select '0076','2013-09-23 00:00:00','2013-09-23 07:11:01',1,15 union all
select '0076','2013-09-23 00:00:00','2013-09-23 10:57:01',1,15 union all
select '0076','2013-09-23 00:00:00','2013-09-23 13:25:01',1,15 union all
select '0076','2013-09-23 00:00:00','2013-09-23 13:27:01',1,15 union all
select '0076','2013-10-25 00:00:00','2013-10-25 08:59:01',2,20
GO
SELECT * FROM TEST; --> 表的结构如下
GO
/*
UID sDate sTime MacID jiange
-------------------- ------------------------------------------------------ ------------------------------------------------------ ----------- -----------
0076 2013-08-11 00:00:00.000 &n