0

Similar issue seen here.

I am trying to run the following command from SSMS running in SQLCMD mode.

:r C:\dev\test scripts\sample.sql

But I get the following error:

A fatal scripting error occurred.
Incorrect syntax was encountered while parsing :r .

I have checked the file, the line endings are appropriate for the Windows machine, and the batch separator matches the settings. What else can I try to run this?

1 Answer 1

1

I was able to resolve this by changing the file name so that it does not include a space:

:r C:\dev\test-scripts\sample.sql
1
  • 5
    Rather than change the file name, you can enclose the path in double-quotes: :r "C:\dev\test scripts\sample.sql"
    – Dan Guzman
    Commented Oct 3, 2023 at 10:43

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.