declare @i int
set @i =7
USE master
SELECT @db_cnt = count(DB_NAME(dbid))
FROM sysdatabases where dbid > 6
select @db_cnt as db_count
while @i<=@db_cnt
begin
SELECT @db_nm=DB_NAME(dbid)
FROM sysdatabases where dbid = @i
ORDER BY dbid
select @db_nm as db_name
USE @db_nm
---> 이부분입니다.
위에서 db_nm 변수에 디비명을 받았는데
use 구문에서 에러가나네요
use 실제디비명 --> 이런식으로 하면 use 문이 먹는데
변수를 사용하면 에러가 나네요 ㅜ.ㅜ
변수 인식할수있는 방법있으면 알려주세요 ...
감사합니다.
|