身份证号码识别性别

ALTER FUNCTION [dbo].[GetGenderByPeopleID]
(
@id VARCHAR(18)
)
RETURNS nchar(1)
AS
BEGIN
 DECLARE @sex AS varchar(3),@gender AS nchar(1)
IF LEN(@id)>=15
begin
 if len(@id)=18
  begin
   set @sex=substring(@id,15,3)
  end
if len(@id)=15
   begin
   set @sex=substring(@id,13,3)
   end
 set @sex=CAST(@sex AS INT)
 if @sex%2=0
    begin
   Set @gender='女'
    end
 else
   begin
   set @gender='男'
   END
END
 RETURN @gender

END

佳麗服飾 淘宝店 佳麗服飾 易趣店

posted @ 2010-06-08 12:54  cyb  阅读(422)  评论(0编辑  收藏  举报