특정테이블의 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

Comments

Powered by Facebook Comments

댓글 남기기

당신의 이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다.

*

다음의 HTML 태그와 속성을 사용할 수 있습니다: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>