how to execute SQL statements in command prompt (CMD),
I'm using SQL Server 2012 in windows 8 OS.
I have tried sqlplus and sqlcmd, both are giving error "
You can also terminate the session by issuing an EXIT statement or (under Unix) by typing Ctrl-D.
Go to Start → Run, type cmd, and hit enter to open the command prompt. Step 2 -SQLCMD -S servername\instancename (where servernameb= the name of your server, and instancename is the name of the SQL instance). The prompt will change to 1→. Step 4 -At the 2→ prompt type go and hit enter.
You are looking for the sqlcmd
utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt
sqlcmd -U myLogin -P myPassword -S MyServerName -d MyDatabaseName
-Q "query"
Refer this
Edit: The OP said The sqlcmd.exe
file is available in the installation path C:\Program Files\Microsoft SQL Server\110\Tools\Binn
You are executing with C:\Users>
make the path to C:\Program Files\Microsoft SQL Server\110\Tools\Binn
and execute sqlcmd
or add the sqlcmd
path (C:\Program Files\Microsoft SQL Server\110\Tools\Binn)
to system PATH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With