0

I'm still pretty new to SQL Server but have a ton of experience with Oracle. How do I run a SQL script while I'm inside a SQLCMD session? Is their something analogous to "SQL>@C:[mypath]\myscript.sql" (Oracle) for SQL Server?

I'm sick of opening scripts and running them using bloated SQL Server Studio.

Blondie
  • 1
  • 1
  • You don't like SSMS? – S3S Jun 08 '17 at 21:15
  • SSMS is an awesome tool and you should learn to use it. Just leave it running to avoid the start-up time. Open a script (or drag and drop a file into it), hit F5, and it runs. You have all sorts of analysis tools available too, examining plans, and browsing the database at your finger tips too. A good SQL Server developer lives in SSMS. – pmbAustin Jun 08 '17 at 21:44

2 Answers2

0

sqlcmd -i file executes a file.

Can't recommend enough to check all the options in the docs.

Alfabravo
  • 7,493
  • 6
  • 46
  • 82
0

I found what I was looking for. You can use this in SQLCMD and in SSMS Query as long as you open it up in "SQLCMD Mode"

:r [path]\myscript.sql

TransactSQL to run another TransactSQL script

Thanks for your responses. Much thanks.

Blondie
  • 1
  • 1