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
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/3809395.html