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