0

I have a database project in Visual Studio Team Services Git, and want to deploy into database on actual server.

(a) Is there setting in publish profile, to drop all objects and recreate?
(b) or is there a setting to create the whole DDL script, rather than just finding schema comparison discrepancy? Want to conduct this from Visual Studio, I know SSMS has option to Generate Scripts for all objects.

Want to conduct for all tables, sprocs, views, not just simple example below. Plan to redeploy and repopulate data warehouse everyday.

Example, say this in Source control database project.

Source Control:

create procedure dbo.SelectTestOne
as 
select 1

And actual server on localdb is

Local Server Discrepancy:

create procedure dbo.SelectTestOne
as 
select 2

Predeployment Script:

If I create a Script.PreDeployment, which drops all objects,

drop procedure dbo.SelectTest

This Final Automatic publish profile Script, will still do an alter, instead of recreate. So question is how do I drop all objects and recreate them? (I know Redgate has this option)

drop procedure dbo.SelectTest
GO

GO
PRINT N'Altering [dbo].[SelectTest]...';


GO
ALTER procedure dbo.SelectTest
as 

select 1
GO
PRINT N'Update complete.';


GO

Note: I do not want to utilize Always-Recreate database, just want to drop all objects Tables, Sprocs, Views in database. I don't want to lose our data or reconfigure logins. Database Project to Drop Database before deploy?

This is for automatic deployment process for devops, we just want to redeploy and populate in same database everyday 2 am after hours.

11
  • If you are dropping the stored procedure then you need to use CREATE PROCEDURE not ALTER PROCEDURE. Commented Mar 27, 2019 at 2:13
  • Out of interest why do you want to drop all and create from scratch? Commented Mar 27, 2019 at 2:16
  • want to validate if our newest code in Git, can repopulate the database from scratch Commented Mar 27, 2019 at 2:17
  • For validation why not just create a fresh database somewhere else? Commented Mar 27, 2019 at 2:18
  • @DaleBurrell this is an automatic deployment process for devops, we just want to redeploy and populate in same database everyday after hours Commented Mar 27, 2019 at 2:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.