日期:2014-05-17 浏览次数:20540 次
create procedure proc_test(
@BUSList nvarchar(max)
)
As
Declare @tmpBusList nvarchar(max)
set @tmpBusList=replace(@BUSList,',',''',''')
Exec ('Select * from tb Where Bus='''+@tmpBusList+'''')
GO
Exec proc_test @BUSList='A103U5,A88888'
CREATE PROCEDURE clbk
@BUSList nvarchar(4000),
@year varchar(20)
AS
Declare @tmpBusList nvarchar(4000)
set @tmpBusList=replace(@BUSList,',',''',''')
exec ('select SpCheckSum.cs_bus AS 车号, Line.c_li_name AS 线路名称,
SoalCodeDb.c_fullname AS 车属单位, SpCheckSum.cs_seat as 座位,dbo.fun_DX(MONTH(SpCheckSum.cs_date))
AS 月份, ISNULL(CAST(sum(case when day(cs_date)=1 then 1 else null end)AS VARCHAR(10)),''×'') ''1日''
FROM SpCheckSum INNER JOIN
Line ON SpCheckSum.cs_line = Line.c_li_id INNER JOIN
SoalCodeDb ON SpCheckSum.cs_comp = SoalCodeDb.c_viewno
WHERE(YEAR(SpCheckSum.cs_date) = @year) AND cs_bus in ('''+@tmpBusList+''') and
(SpCheckSum.cs_disuser IS NULL) AND (SoalCodeDb.c_class = ''营运单位'')
GROUP BY SpCheckSum.cs_bus, MONTH(SpCheckSum.cs_date),
dbo.fun_DX(MONTH(SpCheckSum.cs_date)), Line.c_li_name,
SoalCodeDb.c_fullname,SpCheckSum.cs_seat
ORDER BY cs_bus,MONTH(SpCheckSum.cs_date)')
GO