SQLCMD mode in SSMS allows you to use the command line tool within SSMS. Using this feature of the SSMS, you don’t have to connect SQLCMD using the command prompt. It is really very helpful and less distracting when you want to connect with multiple SQL Server instances. You can follow the below steps to enable at session level.
- Go menu option “Query”
- Click on the SQLCMD mode
Demonstration
- Now open a Query windows type “:connect” syntax to multiple instance;
:connect SQL2K16N1 ---Key here your server name select @@servername as servername go :connect SQL2K16N2 ---Key here your server name select @@servername as servername go :connect SQL2K16N3 ---Key here your server name select @@servername as servername go
- Let’s try to ping your server from SSMS
- Now, let’s check the directly details from SSMS
Hope, you find useful the basic learning of SQL Server!