go if OBJECT_ID('pro_test')is not null drop proc pro_test go create proc pro_test @date date as create table #test( id int identity(1,1), value varchar(2) ) insert #test(value) select '一' union all select '二' union all select '三' union all select '四' union all select '五' union all select '六' union all select '七' union all select '八' union all select '九' declare @yearleft varchar(5),@yearright varchar(5), @month varchar(5),@day varchar(5) select @yearleft=value from #test where id=LEFT(LTRIM(year(@date)),1) select @yearright=value from #test where id=right(LTRIM(year(@date)),1) select @month=value from #test where id=MONTH(@date) select @day=value from #test where id=day(@date) select @yearleft+'00'+@yearright+'-'+'0'+@month+'-'+'0'+@day as newdateexec pro_test '2005-03-05' /* newdate 二00五-0三-0五 */--这个存储过程只能处理2010年以下的时间而且月份是在九月份以内,天实在9号之前
go
if OBJECT_ID('pro_test')is not null
drop proc pro_test
go
create proc pro_test @date date
as
create table #test(
id int identity(1,1),
value varchar(2)
)
insert #test(value)
select '一' union all
select '二' union all
select '三' union all
select '四' union all
select '五' union all
select '六' union all
select '七' union all
select '八' union all
select '九'
declare
@yearleft varchar(5),@yearright varchar(5),
@month varchar(5),@day varchar(5)
select @yearleft=value from #test where id=LEFT(LTRIM(year(@date)),1)
select @yearright=value from #test where id=right(LTRIM(year(@date)),1)
select @month=value from #test where id=MONTH(@date)
select @day=value from #test where id=day(@date)
select @yearleft+'00'+@yearright+'-'+'0'+@month+'-'+'0'+@day as newdateexec pro_test '2005-03-05'
/*
newdate
二00五-0三-0五
*/--这个存储过程只能处理2010年以下的时间而且月份是在九月份以内,天实在9号之前
declare @x varchar(10)
select @x='2005-03-05'select replace(replace(replace(replace(
replace(replace(replace(replace(replace(
@x,'1','一'),'2','二'),'3','三'),'4','四'),'5','五'),'6','六'),'7','七'),'8','八'),'9','九') xx
----------------
二00五-0三-0五