需要在SQL端实现业务逻辑,NND (-_-")
代码一:
ALTER proc [dbo].[tt_select] @Id bigint as select PlanId,FGPartNo,p_FGName from backflush where Id<@Id
代码二:
Declare @Id bigint Set @Id=12 Declare @PlanId nvarchar(100),@FGPartNo nvarchar(100),@FGName nvarchar(100) --确保临时表已经被删除了 IF object_id('tempdb..#t_bf_tmp') IS NOT NULL Begin Drop Table #t_bf_tmp End --定义临时表 Create Table #t_bf_tmp ( PlanId nvarchar(50), FGPartNo nvarchar(50) , p_FGName nvarchar(50) ) --将存储过程的执行结果添加到临时表 Insert Into #t_bf_tmp Exec tt_select @Id --使用游标遍历临时表,并做对于处理 Declare MyCursor Cursor For Select * from #t_bf_tmp For Read Only Open MyCursor Fetch next From MyCursor Into @PlanId,@FGPartNo,@FGName while(@@FETCH_STATUS = 0) Begin print @PlanId Fetch next From MyCursor Into @PlanId,@FGPartNo,@FGName End Close MyCursor Deallocate MyCursor Drop Table #t_bf_tmp