0

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
Ben Pilbrow
  • 12,041
  • 5
  • 36
  • 57
user46529
  • 137
  • 1
  • 6

2 Answers2

2

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
squillman
  • 37,883
  • 12
  • 92
  • 146
0

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.

mrdenny
  • 27,174
  • 4
  • 41
  • 69