影子博客

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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

posted on 2016-03-30 09:41  影子博客  阅读(128)  评论(0编辑  收藏  举报