Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I run the following on SQL Server 2008 R2, I am getting Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ':'. What is wrong?


USE msdb  
share|improve this question
up vote 0 down vote accepted

You need to enable SQLCMD mode in SSMS. Click on the Query drop down menu, then select "SQLCMD Mode". Then you can run the query.

share|improve this answer

Remove the parenthesis around local and the GO on that line. Also, GO statements should be on separate lines by themselves (which I see you had in your source and was just a formatting abnormality).

:CONNECT local
USE msdb
share|improve this answer
The syntax is good, I have to enable cmd mode to execute cmd commands – user46529 Jan 22 '11 at 13:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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