sqlserver存储过程中循环遍历结果集?sql1=select*from(select*,row_numberover(orderbyusername)asrowNumberfromuserswhereregfrom="&admin&")astwheret.rowNumber>0andt.rowNumber<=030orderbyusername怎么会有27条记录呢,除非你的表一共就27条记录吧。用游标或临时表--游标declareyoubiao1for查询1openyoubiao1fetchnextfromyoubiao1into变量while@@FETCH_STATUS=0begin里面一次套用end--临时表declare@IDintset@ID=1whileExists(select*from表)begin--处理--set@ID=@ID1end

declarexvarchar2(20)v_lengthintyintv_strvarchar2(1)beginx:="wqr3331412rr"selectlength(x)intov_lengthfromdualy:=1whiley<=v_lengthloopselectsubstr(x,y,1)intov_strfromdualdbms_output.put_line(v_str)y:=y1endloopend
直接运行吧,结果如图
售后响应及时
7×24小时客服热线
数据备份
更安全、更高效、更稳定
价格公道精准
项目经理精准报价不弄虚作假
合作无风险
重合同讲信誉,无效全额退款