如何将变量用作数据库上下文?
Create Procedure [dbo].[prName] (@dbname varchar(25)) as
begin
use master
some sql
<!-- I need to use master for some functions stored in master -->
use @dbname
exec('SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE [TABLE_CATALOG] = '+@dbname+' and TABLE_NAME=table123')
end
GO
谢谢