views:

159

answers:

1

Trying to use:

:On Error exit

:r D:\opt\db_objects\REPORTS\dbo.sp_ReportCountLORUsers.sql

...and I get:

Msg 102, Level 15, State 1, Line 5 Incorrect syntax near 'U'. ** An error was encountered during execution of batch. Exiting.

What am I missing?

+1  A: 

Perhaps a syntax error in dbo.sp_ReportCountLORUsers.sql ?

Remus Rusanu
In my shame, yes - the sproc itself wouldn't run when copy/pasted into Management Studio.
OMG Ponies
Update: I'm unable to run multiple `:r` statements in SQLCMD mode
OMG Ponies
Add a GO after each :r
Remus Rusanu
Do you have GO inside the :r run scripts? Eg. inside dbo.sp_ReportCountLORUsers.sql ? The documentation of :r says: *it loads the file into the sqlcmd buffer and it sends it to the server at next GO*. I don't have a server handy to test now, but as I read it GOs are allowed only in the parent script, and the included script should not have GO or the 'GO' itsself is sent to the SQL, which does not understand it.
Remus Rusanu