SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Why SQLCMD?


Why SQLCMD?

Author
Message
Shadab Shah
Shadab Shah
SSC-Addicted
SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)

Group: General Forum Members
Points: 445 Visits: 798
Days by day i am learning something new in SQL Server. Before learning anything i want to understand why do we need this feature. This is the same case when i am learning SQLCMD.

I would like to know what are the thing that can be done through SQLCMD which are not possible through SSMS.
Or are there any advantages that while doing a certain set of task through SQLCMD.

Thanks in advance.
Elliott Whitlow
Elliott Whitlow
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10270 Visits: 5314
Are you referring to the command SQLCMD vs the Management Studio or SQLCMD mode in Management Studio?

CEWII
Shadab Shah
Shadab Shah
SSC-Addicted
SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)

Group: General Forum Members
Points: 445 Visits: 798
Elliott Whitlow (6/19/2013)
Are you referring to the command SQLCMD vs the Management Studio or SQLCMD mode in Management Studio?

CEWII


well since I am a newbie. it would be great to know the difference of both.
Elliott Whitlow
Elliott Whitlow
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10270 Visits: 5314
The command SQLCMD is a command line interface to SQL, you type in SQL commands and type GO and it does them. It also allows you to execute a set of commands in a file from the command line. There is not much of an interface and no GUI.

The management studio provides a nice GUI to work with to do many management tasks, most of which could be accomplished using the SQLCMD command.

The SQLCMD mode of management studio allows for some conditional logic and string replacement. I don't use it often.

Without getting too deep there you are..

CEWII
Shadab Shah
Shadab Shah
SSC-Addicted
SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)SSC-Addicted (445 reputation)

Group: General Forum Members
Points: 445 Visits: 798
Elliott Whitlow (6/19/2013)
The command SQLCMD is a command line interface to SQL, you type in SQL commands and type GO and it does them. It also allows you to execute a set of commands in a file from the command line. There is not much of an interface and no GUI.

The management studio provides a nice GUI to work with to do many management tasks, most of which could be accomplished using the SQLCMD command.

The SQLCMD mode of management studio allows for some conditional logic and string replacement. I don't use it often.

Without getting too deep there you are..

CEWII


thanks for such quick reply.
but still the same question is there anything that SQLCMD does and SSMS doesn't.
HanShi
HanShi
SSCarpal Tunnel
SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)

Group: General Forum Members
Points: 4456 Visits: 3672
Because SQLCMD is a commandprompt utility it can be used to automate actions. Consider a scenario in which you need to execute 50 different scriptfiles to update an application database.
- In SSMS you can open each scriptfile and execute it. Each time you need to open the file, press the [execute] button and close the file. This is very time consuming and boring to do.
- With the help of some dynamic coding you can generate a batchfile with all the needed SQLCMD command lines that execute each scriptfile. To execute the complete update process of 50 files you only have to execute the single batch file.

You'll have to generate the dynamic code to generate the batchfile, but once you have created it, it can be used time-and-time again to generate new batchfiles.

SSMS is a good utility to do ad-hoc work and when you need an overview of settings/results.
SQLCMD is a good utility to automate your actions.

** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
Elliott Whitlow
Elliott Whitlow
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10270 Visits: 5314
HanShi makes great points and is correct.

Also I don't think the SQLCMD command line program has a SQLCMD mode like SSMS does. But that isn't used quite as much anyway so no real loss.

SSMS has the ability to show you things in a "pretty" way and SQLCMD does not..

CEWII
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search