IF EXISTS(SELECT * FROM SYS.OBJECTS WHERE TYPE='P' AND NAME='sp_Query') DROP PROC sp_Query create proc sp_Query @Name nvarchar(50), @Date datetime AS SELECT Id,Name,Time1,Time2 FROM Staff WHERE NAME=@Name AND Date=@Date --执行 EXEC sp_Query '张三','2012-10-26'
最大时间-最小时间 当天的啊
CREATE PROC BEGIN SELECT name ,DATEDIFF(mi,'上班时间','下班时间') AS 上班时间(分) FROM TABLE END
CREATE PROC proc_name