时间:2021-05-02
第一种方法:
复制代码 代码如下:
CREATE proc [dbo].[delAllRecord]
as
declare @tableName nvarchar(255)
declare @Sql nvarchar(255)
Declare curTable Cursor
for select Table_Name from information_schema.tables where TABLE_TYPE='BASE TABLE'
Open curTable
Fetch Next From curTable Into @tableName
WHILE(@@FETCH_STATUS = 0)
BEGIN
set @Sql = N'delete from '+@tableName
exec sp_executesql @sql
Fetch Next From curTable Into @tableName
end
CLOSE curTable
DEALLOCATE curTable
第二种方法:
复制代码 代码如下:
--declare test_cursor cursor scroll for
--select id,table_name from dbo.section_type
--open test_cursor
--declare @id int
--declare @table_name nvarchar(50)
--while @@fetch_status=0
--begin
--fetch next from test_cursor into @id,@table_name
--print @id
--print @table_name
--end
--close test_cursor
--deallocate test_cursor
--删除projectrangtree的脏数据
delete from projectrangtree where deleteversion>0
delete from projectrangtree where type=3 and parentid not in(select id from projectrangtree where type=2)
delete from projectrangtree where type=4 and parentid not in(select id from projectrangtree where type=3)
delete from projectrangtree where type=5 and parentid not in(select id from projectrangtree where type=4)
--删除section_settings的脏数据
delete from section_settings where parent_prj_tree_id not in(select id from projectrangtree)
--删除各个表里的测点
declare @table_name varchar(50)
declare @sql nvarchar(500)--此处要注意,声明的长度一定要够
--declare @measuring_point_id nvarchar(500)
declare del_cursor cursor scroll for
select table_name from section_type
open del_cursor
fetch next from del_cursor into @table_name
--print @table_name
while (@@fetch_status=0)
begin
--print quotename(@table_name)
--set @measuring_point_id='select measuring_point_id from '+quotename(@table_name)
--exec sp_executesql @measuring_point_id
set @sql = 'delete from '+ quotename(@table_name) +' where measuring_point_id not in(select id from measuring_point_setting)'
exec sp_executesql @sql
--delete from @table_name where measuring_point_id not in (select id from measuring_point_setting)
fetch next from del_cursor into @table_name
end
close del_cursor
deallocate del_cursor
--delete from (select talbe_name from section_type) where measuring_point_id not in (select id from measuring_point_setting)
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
以前说过的趋势挂马事件,MS这个挂马方法已经流行了很久,从去年就大规模开始了,在网上可以搜到很多痕迹。SQL语句如下:用游标遍历所有表里如下数据类型的字段,然后
当我们需要批量删除数据库中的表时,对于单个删除一些表是否感到烦躁,厌倦,干脆写个脚本用得了。本脚本使用游标循环删除,对于数量比较小,用游标暂不会造成恶劣影响。复
多层索引的创建普通-多个index创建在创建数据的时候加入一个index列表,这个index列表里面是多个索引列表Series多层索引的创建方法importpa
Truncatetable语句用来删除/截断表里的所有数据和delete删除所有表数据在逻辑上含义相同,但性能更快类似执行了droptable和createta
电子游标卡尺使用的方法如下: 1、首先按下游标卡尺上的OFF/ON按钮,然后打开电子游标卡尺。 2、打开后的游标卡尺,有时候会显示数据,这是因为卡尺未合拢,