I've been searching for a "definitive" solution to this for a couple of hours now and can't find out exactly what the problem is so am hoping someone can point me in the right direction.
I'm trying to create a script for a database (an MDF file DB) on a remote machine and use it to create the same database locally. I've got Visual Studio 2010 on both machines so used the Database Publishing Wizard to generate the script.
I next created a blank DB in Visual Studio locally (another MDF file DB) and selected to create a new query. I've pasted the copied script in but when I try and run it I get dozens of "incorrect syntax near GO" errors. I'm not sure how many in total as the alert pop-up goes off the bottom of my screen. It would seem to be a lot though.
I trimmed off all but the very top of the script and I still get the same errors with it. It now looks like this:
SET ANSI_NULLS ON
GO
I still get the "incorrect syntax near GO" error with this.
Is there something inherently wrong with the scripts this tool generates or am I doing something wrong with it?
The remote DB is 2008 R2 and my local is just plain 2008, hence why I don't just copy the MDF file across.
If anyone has any suggestions, they would be most welcome.
From the docs:
GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor.
Either use such a tool to execute the script or omit the GO commands.