select t1.FValue + '年' + t2.FValue + '月' as fname
from t_SystemProfile t1
inner join t_SystemProfile t2 on t1.FCategory =t2.FCategory
where t1.FCategory ='ic' and t1.FKey ='currentyear' and t2.FKey ='currentperiod'
select t1.FValue || '年' || t2.FValue || '月'
from
tablename as t1,
tablename as t2
where t1.FCategory = t2.FCategory
and t1.FKey ='currentyear'
and t2.FKey ='currentperiod'
if exists(select * From sysobjects where type='p' and name='sp_GetCurrPeriod')
Drop Procedure sp_GetCurrPeriod
GO
CREATE proc [dbo].[sp_GetCurrPeriod]
@FCategory nvarchar(30)
as
SET NOCOUNT ON
create table #Tmp1(
FYear nvarchar(255) ,
FPeroid nvarchar(255) ,
)
declare @FPeroid nvarchar(255)
insert into #Tmp1 (FYear)
select fvalue+'年' from t_SystemProfile where FCategory =@FCategory and FKey='CurrentYear'
select @FPeroid=fvalue+'月' from t_SystemProfile where FCategory ='ic' and FKey='CurrentPeriod'
update #Tmp1 set FPeroid=@FPeroid
select FYear+Fperoid as Fperoid from #Tmp1
drop table #Tmp1
GO
存储过程解决但感觉太麻烦,有简单高效的办法吗?