Following is a very simple query executed using this tool:
sqlcmd -S .\SQLEXPRESS -E -Q "Drop Database SampleDB"
Where SampleDB is the database name i want to drop, -S switch specifies the server instance, -E switch specifies that i want to use trusted connection and -Q switch specifies the SQL query i want to execute.
This tool is quite powerful and there are several switches that you can use to meet different requirements. You can open command prompt and see help (sqlcmd /?) for all the different switches that it supports.
1 comment:
There is another command line tool called "osql" as well. But sqlcmd is more feature rich than osql and I usually prefer that.
Post a Comment