Great option “SQLCMD” run DOS command in SQL Server Managment Studio

Dear All,
Today I am going to share one of the interesting options of SQL Server Management studio which may be unknown to most of us.
Now you are thinking what it is? So the cool feature is you can

run DOS command in your SQL Server Management studio

I know your next question is how?
My answer is just follow below step
Go To Tool –> Option
After option window open you need to select Query Execution tree and Select checkbox for


By default, Open new queries in SQLCMD Mode

Now open new Query window and write following command
!! Dir C:\
And hit F5
You will find below in the query result you have directory & files of your current C drive.
Just check below fig to understand.


In this way you can run various DOS commands.
!! Dir C:\New Folder

Isn’t it cool feature.

I hope you enjoyed it.


Keep Learning, Keep Sharing
Your friend,
Rajat Jaiswal

Leave a Reply

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

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.