Declare @dav as varchar(50) ---定义变量,用来保存从游标中取得的值Declare cursor5 cursor for select fl from table ---定义游标
open cursor5 ---打开游标fetch cursor5 into @pdav while @@fetch_status=0 ---循环读取值
begin
exec('delete ' +@表名+' where .....')---执行一定的操作
fetch cursor5 into @dav
endclose cursor5 ---关闭游标Deallocate Cursor5 ---删掉游标
open cursor5 ---打开游标fetch cursor5 into @pdav while @@fetch_status=0 ---循环读取值
begin
exec('delete ' +@表名+' where .....')---执行一定的操作
fetch cursor5 into @dav
endclose cursor5 ---关闭游标Deallocate Cursor5 ---删掉游标
解决方案 »
- 如何快速查找可用编号空位 在线等待 大师请出手
- 存储过程中的有字符的双循环,
- 求一个表返回结果横排的语句
- SQL高手看过来
- 问个查询效率问题,我两张表数据都是60万,我sql语句是:select * from test08 a where a.nbr not in(select nbr from disct@towe where
- 对于此SQL语句该怎么改,一个主表,两个从表
- distinct 为什么不好用啊?
- 请教一条SQL语句
- 初学者的学习-4-->用户,数据库的关系
- adodb.recordset.opn执行后,符合判断是否取得数据集,或为数量为空
- 请经验丰富的DB Developer帮我看看这个问题:关于select …… from
- 数据导入时,出错
set @s=''
select @s=@s+'delete '+tablename+';' from tableindex
exec(@s)
例如
exec('delete from [' +@TableName+'] where detailtime>2005-1-1')---执行一定的操作
怎样将‘2005-1-1’需要的“'”号添加进去?????