1USE AdventureWorks2014;
2GO
3DECLARE @MyVariable int;
4SET @MyVariable = 1;
5-- Terminate the batch by using the GO keyword.
6GO
7-- @MyVariable has gone out of scope and no longer exists.
8
9-- This SELECT statement generates a syntax error because it is
10-- no longer legal to reference @MyVariable.
11SELECT BusinessEntityID, NationalIDNumber, JobTitle
12FROM HumanResources.Employee
13WHERE BusinessEntityID = @MyVariable;
14