Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

:CONNECT(local)  
Go

USE msdb  
go
share|improve this question

2 Answers 2

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
GO
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

 
discard

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.