I am trying to add some stored procedures to a build process in visual studio (using MSBuild) with a database project (*.dbp).
However unlike some of the other database projects available in VS, it cannot be built or run. ( I believe this is the project file i want as I am using SQL2000)
How can I get the SQL scripts to run as I build the project?
I know that I can run the scripts by right clicking and pressing run….but that is not the question.
Database projects are not built like normal projects. If you want to execute scripts inside this project, my advice would be to extend the associated project(s) which are MSBuild compatible (csproj, vbproj, etc.) and reference/execute your scripts from there using your tool of choice.
How you implement it is up to you, for example, you could hook into BeforeBuild target and execute scripts using SqlExecute task.
FWIW, we have to support SQL Server 2000, 2005, 2008+, so the task becomes much harder; think NVarchar(max) (2005+) vs NText (2000+) plus all the sp renames, etc between versions. We also wanted a single script which developers, QA and installer used to ensure consistency. So our approach was a custom tool which allowed token/keyword replacements inside scripts, which provides flexibility between different SQL Server versions and customers installations (e.g. user/login details, db names), as well as integration into various technologies so scripts can run from command line, MSBuild, MSI custom action using Wix projects, or whatever we need them to run from.