最近⼜忘记存储过程 除了exec 动态写法的另外⼀种,这⾥记录⼀下,⽅便查找写法1,动态语句
CREATE PROCEDURE sp_CountShiftWish
@strids varchar (1024) /*strids 是id列表, 类似1,2,3*/ AS
exec ('select * from student where id in('+@strids+')') go
写法2,索引查找
CREATE PROCEDURE sp_CountShiftWish
@strids varchar (1024) /*strids 是id列表, 类似1,2,3*/ AS
select * from student where charindex(','+ltrim(id)+',',','+@strids+',')>0 go
因篇幅问题不能全部显示,请点此查看更多更全内容