一个存储过程,你直接调用就可以了
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
Create PROCEDURE [dbo].[GetBirthDay]
(
@id varchar(30)
)
AS
BEGIN
declare @birthday varchar(30)
if(len(Rtrim(@id))=18)
begin
set @birthday=substring(@id,7,8)
set @birthday=substring(@birthday,1,4)+'年'+substring(@birthday,5,2)+'月'+substring(@birthday,7,2)+'日'
end
else
begin
set @birthday=substring(@id,7,6)
set @birthday='19'+substring(@birthday,1,2)+'年'+substring(@birthday,3,2)+'月'+substring(@birthday,5,2)+'日'
end
select @birthday
END