不知各位项目中会不会保存个人信息的星座属性,我这是项目中遇到了,把代码贴出来供需要的人吧,
SQL Server 函数创建语句:
CREATE FUNCTION [dbo].[f_星座] ( @birthdate datetime ) returns nvarchar(6) AS begin declare @month int, @day int, @result nvarchar(6) set @month = DATEPART(MONTH, @birthdate) set @day = DATEPART(DAY, @birthdate) if ((@month = 1 and @day >= 20) or (@month = 2 and @day <= 18)) begin set @result = '水瓶座'; end else if ((@month = 2 and @day >= 19) or (@month = 3 and @day <= 20)) begin set @result = '双鱼座'; end else if ((@month = 3 and @day >= 21) or (@month = 4 and @day <= 19)) begin set @result = '白羊座'; end else if ((@month = 4 and @day >= 20) or (@month = 5 and @day <= 20)) begin set @result = '金牛座'; end else if ((@month = 5 and @day >= 21) or (@month = 6 and @day <= 21)) begin set @result = '双子座'; end else if ((@month = 6 and @day >= 22) or (@month = 7 and @day <= 22)) begin set @result = '巨蟹座'; end else if ((@month = 7 and @day >= 23) or (@month = 8 and @day <= 22)) begin set @result = '狮子座'; end else if ((@month = 8 and @day >= 23) or (@month = 9 and @day <= 22)) begin set @result = '处女座'; end else if ((@month = 9 and @day >= 23) or (@month = 10 and @day <= 23)) begin set @result = '天秤座'; end else if ((@month = 10 and @day >= 24) or (@month = 11 and @day <= 22)) begin set @result = '天蝎座'; end else if ((@month = 11 and @day >= 23) or (@month = 12 and @day <= 21)) begin set @result = '射手座'; end else if ((@month = 12 and @day >= 22) or (@month = 1 and @day <= 19)) begin set @result = '摩羯座'; end return @result end