Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Why SQLCMD? Expand / Collapse
Author
Message
Posted Wednesday, June 19, 2013 12:59 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 2:32 PM
Points: 261, Visits: 641
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.
Post #1465341
Posted Wednesday, June 19, 2013 2:08 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, May 15, 2014 5:11 PM
Points: 6,067, Visits: 5,283
Are you referring to the command SQLCMD vs the Management Studio or SQLCMD mode in Management Studio?

CEWII
Post #1465375
Posted Wednesday, June 19, 2013 2:14 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 2:32 PM
Points: 261, Visits: 641
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.
Post #1465378
Posted Wednesday, June 19, 2013 2:31 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, May 15, 2014 5:11 PM
Points: 6,067, Visits: 5,283
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
Post #1465384
Posted Wednesday, June 19, 2013 10:15 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 2:32 PM
Points: 261, Visits: 641
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.
Post #1465451
Posted Thursday, June 20, 2013 6:33 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 7:50 AM
Points: 2,262, Visits: 2,725
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’! **
Post #1465644
Posted Thursday, June 20, 2013 9:04 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, May 15, 2014 5:11 PM
Points: 6,067, Visits: 5,283
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
Post #1465757
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse