2

Hello is it possible to run .sql file with parameter

like

:R c:\scripts\<scrips1>.sql,<param>
:R c:\scripts\<scrips2>.sql,<param>
3
  • Where are you trying to "execute" these from? .SQL files open in SQL Server Management Studio where you can execute them there; they don't execute outside of that. Commented May 13, 2014 at 11:45
  • Possible duplicate of this... stackoverflow.com/questions/9010359/… Commented May 13, 2014 at 11:46
  • @roryap you can execute them from a command line. Commented May 13, 2014 at 11:49

1 Answer 1

3

Try this:

sqlcmd -E -S <Server name> -v test="Some value" -i YourSqlFile.sql

Also check Use sqlcmd with Scripting Variables

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.