mssql函数demo

ALTER FUNCTION [dbo].[f_GetCookType]
(
@saleDate datetime
)
RETURNS varchar(6)
AS
BEGIN
declare @cookType varchar(6)
declare @time datetime

Select @time=CONVERT(varchar(100),@saleDate, 24)
if @time>='06:00:00' and @time<='10:00:00' begin
set @cookType='早餐'
end else if @time>='10:00:01' and @time<='14:00:00' begin
set @cookType='午餐'
end else if @time>='14:00:01' and @time<='20:00:00' begin
set @cookType='晚餐'
end else if @time>='20:00:01' and @time<='23:59:59' begin
set @cookType='夜宵'
end

RETURN @cookType
END

上一篇:EL表达式具体解释


下一篇:如何禁止IE自动生成链接