12

SQLServer 2005 introduced something called SQLCMD Mode msdn link.

At first glance this mode adds variable subsitution from command line batch files, and some escaping to OS commands.

Is this feature used in your environments, production or test?

  • I know it's a bit late but I feel I should close this question as the way it is phrased it solicits multiple equally valid answers (see the faq for more details) – Jack says try topanswers.xyz Nov 3 '12 at 5:12
4

I use the sqlcmd mode in SSMS on occasion. Typically when migrating databases from one environment to another. For example if I need to backup the database from production, then restore it to dev, I'll do this all in one script using SQLCMD mode to switch servers. I've used to here and there for one thing or another, but I don't use it all that often.

4

I actively use this when deploying logshipping as it allows me to do everything within a single script connecting to the primary, monitor and secondary servers.

2

Used it as well in doing data processing before we migrated over to SSIS. It is definitely a useful feature.

2

I'm using sqlcmd mode mostly for changing servers in a single script. But the nicest feature for me is that I can combine batches and sql files in a single package (a combination of running a report + an ssis package to import/export data in csv file + some data change scripts).

One can execute sql files from batches using parameters provided from a central batch file that executes everything and has all parameters in one place. That's a sweet thing for me!

1

I think, SQLCMD a great tool, it replaces old ones ISQL and OSQL starting from sql server 2k5. It lets you enter TSQL statements, system procedures, and script files at the command prompt. And MSSMS has implemented calls of this tool.

  • I'm using sqlcmd as replacement for osql myself, but I'm not using the new features. I want to know if those where used. – bernd_k Jan 10 '11 at 6:13
-1

I use sqlcmd for running admin scripts, batch jobs and reports. I also use sqlsplus, which is like Oracle SQL*Plus, but for SQL Server (found it at www.sqlsplus.com)

Not the answer you're looking for? Browse other questions tagged or ask your own question.