본문 바로가기
Database/MSSQL

cursor , open , declare , 커서를 이용한 카운트 구하기

by 반화넬 2007. 11. 14.
반응형

use pubs
go

declare curGetTableName INSENSITIVE CURSOR
for
select count(*) from information_schema.tables
where table_type='base table'
for read only
go

open curGetTableName
--select @@CURSOR_ROWS
go

declare @@tmp varchar(30)

fetch next
from curGetTableName into @@tmp
--select @@fetch_status
print @@tmp
go

close curGetTableName
deallocate curGetTableName
go

반응형