Simon's SQL

SQL,DBA,tuning,Trouble Shooting,Performance

SQLCMD mode in SSMS

Posted by Simon Cho on 02/01/2017

SQLCMD mode in SSMS

Here are some commands very useful. Things help to deploy complicated queries.

 

:CONNECT localhost
:setvar DBA “DBA”

:on error exit
GO

USE [$(DBA)]
go
SELECT DB_NAME()

print ‘abc.sql – Simon’

:r c:\temp\abc.sql
GO
print ‘abcdef.sql – Simon’
:r c:\temp\abcdef.sql
GO

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s