SQL Server: Bulk Delete table via sys.tables, or roll back table
1 beginTry2 Drop Table#temp103 EndTry4 beginCatch5 EndCatch6 7 Select 'drop/*truncate*/table tuning.'+Name asDroptable,row_number () Over(Order byName asRowNumber8 into#temp109 fromSys.tableswhereName like 'member%' andSchema_name (schema_id)='dbo'Ten One Select * from#temp10 A - Declare @rownumber int; - Declare @records int; the Declare @droptable nvarchar( -); - - Select @records=MAX(RowNumber) from#temp10 - + Set @rownumber=1; - + while @rownumber<=@records A begin at Select @droptable =Droptable from#temp10whereRowNumber=@rownumber - Print @droptable - execsp_executesql@droptable - - Set @rownumber=@rownumber+1; - End
Dynamic statistics Database, the number of records inserted in a table per second
1 Declare @records int;2 3 while 0=04 begin 5 waitforDelay'00:00:01' --1s per interval, executed once6 7 Select @records=IsNull(sum(T10.rows),0)8 fromSys.partitions asT109 Inner JoinSys.objects asT11 onT10.object_id=T11.object_idTen whereT11.name like 'member%' One andT10.partition_number=2 --The current data is inserted into that partition and the partition is written. If there is no partition, the condition can be added without A andt10.index_id>=2 - - Print @records the End
SQL Server: Sys.tables for bulk deletion of tables, fast statistics of multiple table records and