ALTER PROCEDURE pr_getQuerDianxin
@flag INT=0,
@dianxingList VARCHAR(200)=NULL,
@splitChar VARCHAR(5)='*'
AS
if @flag=1
begin
--SELECT * INTO #shclist from dbo.f_split('BC0231934BC0230267BC0230770BC0231935BC0230761BC0230250BC0230171','*' )
SELECT * INTO #shclist from dbo.f_split(@dianxingList,@splitChar)
--申明一个游标
DECLARE MyCursor CURSOR FOR SELECT col from #shclist
--打开一个游标
OPEN MyCursor
--循环一个游标
DECLARE @col varchar(20)
FETCH NEXT FROM MyCursor INTO @col WHILE @@FETCH_STATUS =0
BEGIN
SELECT obj FROM beilvsanTwo WHERE dianXin=@col
FETCH NEXT FROM MyCursor INTO @col
END
--关闭游标
CLOSE MyCursor
--释放资源
DEALLOCATE MyCursor
END