2

I have a database project in Visual Studio 2010 that targets SQL Server 2012 and at least one of the stored procedures uses the new syntax for rethrowing errors ("THROW;")

Trying to build the project from command line like so :

msbuild /t:Build MyDatabaseProject.dbproj

outputs this :

Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.269]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 28.08.2012 13:14:23.
Project "F:\My\Path\MyDatabaseProject.dbproj" on node 1 (Build target(s)).
DspBuild:
  Creating a model to represent the project...
  Loading project files...
  Building the project model and resolving object interdependencies...
  Validating the project model...
F:\MY\PATH\SCHEMA OBJECTS\SCHEMAS\DBO\PROGRAMMABILITY\STORED PROCEDURES\SOMEPROC.PROC.SQL(95,3,95,3): Build error SQL02010: Incorrect syntax near THROW. [F:\My\Path\MyDatabaseProject.dbproj]
...

My guess is that I should add a parameter to specify the SQL Server 2012 T-SQL dialect but I am not sure about this.

Building the project from Visual Studio works without any issues.


UPDATE : I am not exactly sure what type of project I have. The project properties looks like so :

enter image description here

Additional data :

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Andrei Rînea
  • 20,288
  • 17
  • 117
  • 166

1 Answers1

3

It looks like you're using the old database project type which only supports up to SQL Server 2008. There is a new database project type that supports SQL Server 2012 (with the very generic name "SQL Server Database Project") for Visual Studio 2010 that you can install as part of the latest version of SQL Server Data Tools.

The new project type requires a different command line syntax which you can find here.

By the way Visual Studio can easily convert your existing database project to the new project type.

Community
  • 1
  • 1
Keith
  • 20,636
  • 11
  • 84
  • 125
  • I have installed the Data Tools required for Visual Studio to handle this project and, as told, I can build the project with no problem using the Visual Studio. – Andrei Rînea Aug 29 '12 at 10:42
  • The .dbproj extension of your project means you're still using the old project template. The old template doesn't support SQL Server 2012. – Keith Aug 29 '12 at 13:23
  • Well, I did found a dacpac file in the .\sql\debug folder. Would that be? – Andrei Rînea Aug 29 '12 at 14:10
  • Nope. There is no sql folder with the new template. (The .dacpac file gets written to bin\Debug.) You'll need to upgrade your project by right-clicking it in Visual Studio's Solution Explorer and select [Convert to SQL Server Database project](http://www.sqlnotes.info/wp-content/uploads/2012/04/DataTool03.png). – Keith Aug 29 '12 at 14:40
  • Hm... I don't seem to have that menu command. However it seems that I was wrong, the main project file is a .sqlproj not .dbproj (the dbproj is a leftover as it seems). – Andrei Rînea Aug 29 '12 at 16:47
  • I've added all the screenshots I thought could be of use to identify this type of project.. – Andrei Rînea Aug 29 '12 at 17:02
  • You're definitely using the new project template. Now you need to use `SqlPackage.exe` instead of `msbuild`. – Keith Aug 29 '12 at 17:29