Click here to Skip to main content
15,881,027 members
Articles / Database Development / SQL Server / SQL Server 2008
Alternative
Tip/Trick

Execute SQL Query / SQL Command on SQL Server Using the Command Prompt

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
3 Feb 2012CPOL 12.9K   2
SQLCMD can be used to login to the Sql Server as well. One can only provide Server address, User Name and Password at the command prompt and press enter.The command prompt will change to 1>. Now any sql query can typed and by pressing enter in the next prompt a GO command and pressing enter...
SQLCMD can be used to login to the Sql Server as well. One can only provide Server address, User Name and Password at the command prompt and press enter.
The command prompt will change to 1>. Now any sql query can typed and by pressing enter in the next prompt a GO command and pressing enter will execute the query and show the result on the screen.

This can be used when there is no SSMS available and just need to check any tables or execute any queries for maintenance.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Safaltek Software
India India
Working for over 20 years now and still learning.
Working for a product base company building solutions for the marine world.

Comments and Discussions

 
Generalwe may have morethan one database, within that so many table... Pin
rajigopalan7-Feb-12 21:22
rajigopalan7-Feb-12 21:22 
GeneralRe: on script.sql, you may to use different database, as long as... Pin
IkhwanKrisnadi12-Feb-12 17:15
IkhwanKrisnadi12-Feb-12 17:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.