You can use the following utilities to execute Transact-SQL statements and stored procedures:
The SQL Server Management Studio is the most frequently used tool. It has a graphical user interface and is therefore easy to use. In addition, it offers quick access to help on the syntax of commands.
sqlcmd is a command line utility. The advantage of this tool is that it allows the specification of input and output files for scripts and therefore allows you to automate and schedule the execution of scripts.
Procedure
The SQL Server Management Studio
A new query window opens in the right pane.
The results are displayed in a lower pane.
The sqlcmd Utility
The sqlcmd utility allows you to execute Transact-SQL statements, stored procedures and script files.
To execute a script with the sqlcmd utility, enter a command as follows in the command prompt:
sqlcmd -S<server_name>[\<instance name> -d<SAPSID> -U<login> -P<password> -i<script_name> -o<output_file>
For more information, see the topic sqlcmd utility in the SQL Server Books Online.