특정테이블의 row수, 사이즈등을 알고 싶을때 쓰는 프로시져

– 특정 테이블만 알고 싶을때
EXEC sp_spaceused ‘테이블명’;

– 특정디비의 모든 테이블에 대해서 알고 싶을때
use mousebbs
go
exec sp_MSforeachtable “exec sp_spaceused ‘?'”

– 조건에 따른
use mouseBBS
go
declare @tblName varchar(30)
declare curGetTableName INSENSITIVE CURSOR

for
select tableName from tableinfo where groupcode=2
for read only

open curGetTableName

fetch from curGetTableName into @tblname

while @@FETCH_STATUS = 0
begin
exec sp_spaceused @tblName
FETCH FROM curGetTableName INTO @tblName
end

close curGetTableName
deallocate curGetTableName
go

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다