Wednesday, March 24, 2010

Using Command Prompt for running SQL commands

Usually on the costumer's computer, if you installed an instance of Microsoft SQL Server Express, you will not install the management studio to prevent the user from using it badly and harm your valued database. But in this case you might need to run a SQL command.

You can use the command prompt to do the job.

From command prompt you can run a 'sqlcmd'.

The simplified syntax for that is 'sqlcmd -S servername'. ex. 'sqlcmd -S adel-pc\SQLEXPRESS' and now you are on the sever and you can run any Select, Update, delete , backup, restore .. etc comands or any sql command you want by accessing database for example 'USE master GO' and so on ...

You can find here a full description of sqlcmd.

Have fun.

No comments:

Post a Comment