日期:2014-05-17 浏览次数:20547 次
create procedure getzm
@n varchar(10)
as
begin
create table #t_number(number varchar(10))
create table #t(coltest varchar(2))
insert into #t select 'A'
insert into #t select 'B'
insert into #t select'C'
insert into #t select'D'
insert into #t select 'E'
insert into #t select'F'
insert into #t select'G'
insert into #t select'H'
insert into #t select'I'
create table #t1(coltest varchar(2))
insert into #t1 select 'A'
insert into #t1 select 'B'
insert into #t1 select'C'
insert into #t1 select'D'
insert into #t1 select 'E'
insert into #t1 select'F'
insert into #t1 select'G'
insert into #t1 select'H'
insert into #t1 select'I'
insert into #t_number select number from master .dbo.spt_values where type ='p' and number <=100
insert into #t_number select #t1.coltest +#t.coltest from #t cross join #t1
if ISNUMERIC(@n)>0
begin
select number+1 from #t_number where number=@n
end
else
begin
declare @m varchar(10)
set @m=@n
set @n=SUBSTRING (@n ,0,2)+'%'
create table #temp (number varchar(10),number2 int)
insert into #temp select t.number,t .rownum as number2 from (select number, ROW_NUMBER() over (order by number desc ) as rownum from #t_number where #t_number.number like @n ) t
select number from #temp where number2=(select number2-1 from #temp where