I have imported an existing SQL Server 2008 database to a Visual Studio 2008 database project, to version control database objects and perform database code migration. This works fine and I can build and deploy to dev, test, staging, live etc.
Now I want to add a new stored procedure (with a grant statement) to the existing database project and cannot see an ideal way to do this? I can either: -
- Create the stored procedure in the development database, reverse engineer a script, and “import script” to my Visual Studio project.
- Create the stored procedure directly in my Visual Studio project, but the grant statement raises an error there, so I will have to manually edit the xml in the “Database.sqlpermissions” script.
- Create the stored procedure directly in my Visual Studio project. Then add the GRANT statement to the “Script.PostDeployment.sql” file. But now my permissions are spread across two files “Database.sqlpermissions” and “Script.PostDeployment.sql”.
What is the preferred way to add a new stored procedure with a grant statement to an existing Visual Studio 2008 database project?