[转]sql利用游标循环,遍历表循环结果集
摘要:
用 游标(Cursor) + While循环 的方法, 对Customers表中的CompanyName列进行遍历declare @customer nvarchar(50)declare pcurr cursor forselect distinct companyname from customersopen pcurrfetch next from pcurr into @customerwhile (@@fetch_status = 0)begin print (@customer) fetch next from pcurr into @customerendclose pcurr. 阅读全文
posted @ 2013-06-20 16:35 悉野 阅读(267) 评论(1) 推荐(0) 编辑