日期:2014-05-17 浏览次数:20616 次
create proc p_test
@table varchar(200)
as
if object_id (N'dbo.test', N'procedure') is null
Begin
declare @sql varchar(1000)
set @sql = 'create procedure test @pram varchar(20) as select * from '+@table+' where ID=@pram '
execute(@sql)
END
alter proc test
@table varchar(200)
as
declare @sql varchar(max)
set @sql='select * from '+@table
exec(@sql)
add('if exists (select 1 from sysobjects where name=''GetList'' and type=''p'')');
add('drop procedure GetList');
EXECSQL;
Close;
clear;
add('create procedure GetList');
add('@table varchar(20),@classes varchar(20)');
add('as');
add('begin');
add('declare @sql as varchar(100) ');
add('set @sql=''select * from ''+@table+'' where 1=1'' ');
add('IF(@classes<>0)');
add('set @sql = @sql+''and classes='' + @classes');
add('exec(@sql)');
add('end');