sql server游标: --定义游标 declare cursor1 cursor for select ID,Name from A --打开游标 open cursor1 declare @id int declare @name varchar(50) declare @n int declare @i int=1 set @n=(select COUNT(1) from A) while(@i<@n) begin set @i=@i+1 fetch next from cursor1…
原文:SQL Server 游标运用:查看所有数据库所有表大小信息(Sizes of All Tables in All Database) 一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 实现代码(SQL Codes) 方法一:游标 + 系统存储过程sp_MSForEachDB 方法二:封装sp_MSforeachtable + sys.databases 方法三:系统存储过程sp_MSForEachDB + sp_MSforeacht…
原文:SQL Server 游标运用:查看一个数据库所有表大小信息(Sizes of All Tables in a Database) 一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 实现代码(SQL Codes) 方法一:运用游标 方法二:运用系统存储过程 方法三:拼接SQL 参考文献(References) 二.背景(Contexts) 在性能调优或者需要了解某数据库表信息的时候,最直观的方式就是罗列出这个数据所有表的信息,这些信息…