CREATE FUNCTION [dbo].[IDCard18To15] (@id_card varchar(24))
RETURNS varchar(18) AS
BEGIN
declare @x2 varchar(18)
if len(@id_card)=18 --18位禅渣
begin
select @x2=stuff(@id_card,18,1,'')
select @x2=stuff(@x2,7,2,'知扮'贺猛悄)
end
else if len(@id_card)=15 --15位
select @x2=@id_card
return @x2
END