Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Running a SQL Script from a SQL Command Line.
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

12 Posts

Posted - 08/20/2014 :  13:57:05  Show Profile  Reply with Quote
Hi im trying to execute a SQL Script from SQL commandline within management studio.

however get the error .

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

the following is what I run.(I use % for spaces?)
:setvar path "F:\Centre%of%Credit%Excellence\Development\2.%Prep%Scripts\"
:setvar DataFile "ImportScript_EDIT.sql"

any ideas?

Almighty SQL Goddess

38200 Posts

Posted - 08/20/2014 :  14:20:56  Show Profile  Visit tkizer's Homepage  Reply with Quote
When I am in sqlcmd mode and check the syntax of what you posted, it checks fine.

I would switch the % to spaces though as the double quotes handle the paths/file names that have spaces.

Tara Kizer
SQL Server MVP since 2007
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.13 seconds. Powered By: Snitz Forums 2000