/*============================================================================
  File:     SQLCMDConnectToExercise.sql

  Summary:  This script uses the sqlcmd :CONNECT option... but helps you to 
			understand how it works. SQLCMD commands are executed for each 
			batch so without a batch delimiter you might not get the results
			you are expecting.

			NOTE: You must be using SQLCMD mode of execution if you are using
			SQL Server Management Studio.

  Date:     May 2005

  SQL Server Version: 9.00.1116 (IDW14)
------------------------------------------------------------------------------
  Copyright (C) 2005 Kimberly L. Tripp, SYSolutions, Inc.
  All rights reserved.

  For more scripts and sample code, check out 
    http://www.SQLskills.com

  This script is intended only as a supplement to demos and lectures
  given by Kimberly L. Tripp.  
  
  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF 
  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 
  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  PARTICULAR PURPOSE.
============================================================================*/

----------------------------------------------------------------------------
-- Batch 1: Verify the output of @@servername for multiple connections
----------------------------------------------------------------------------

:CONNECT SQLIDW15HA

select @@servername

:CONNECT SQLIDW15HA\SQLDev01

select @@servername

:CONNECT SQLIDW15HA\SQLDev02

select @@servername

:CONNECT SQLIDW15HA\SQLExpress

select @@servername
go

----------------------------------------------------------------------------
-- Batch 2: Verify the output of @@servername for multiple connections
----------------------------------------------------------------------------

:CONNECT SQLIDW15HA

select @@servername
go

:CONNECT SQLIDW15HA\SQLDev01

select @@servername
go

:CONNECT SQLIDW15HA\SQLDev02

select @@servername
go

:CONNECT SQLIDW15HA\SQLExpress

select @@servername
go