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?

asked Oct 3, 2023 at 10:16

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
answered Oct 3, 2023 at 10:16
1
  • 5
    Rather than change the file name, you can enclose the path in double-quotes: :r "C:\dev\test scripts\sample.sql" Commented Oct 3, 2023 at 10:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.