3> USE master
4> GO
Changed database context to 'master'.
1>
2> DECLARE @DBName nvarchar(128)
3> DECLARE @TBLName nvarchar(128)
4> SET @DBName = N'Northwind'
5> SET @TBLName = N'Shippers'
6>
7>
8>
9> SELECT name
10> FROM sys.databases
11> WHERE name = @DBName
12> GO
name
--------------------------------------------------------------------------------------------------------------------------------
(0 rows affected)
1> SELECT name, object_id
2> FROM sys.tables
3> WHERE name = @TBLName
4> GO
Msg 137, Level 15, State 2, Server J\SQLEXPRESS, Line 3
Must declare the scalar variable "@TBLName".