More on Refactoring in SSDT

I wanted to make a few more points about using SSDT in addition to previous posts.  As I was working on my project, I wanted to drop a procedure that was no longer used, but there is nothing on re-factor menu to support that.  Come to find out, you have to follow a different pattern of development.  For example, I added a History table in my previous example:

image

I can deploy my solution to create this new table.  By the way, if I have multiple publish profiles (*.publish.xml files), I can pick a default one by right clicking on it, then selecting Set as Default Publish Profile option.  From that point on, if you right-click on project and select Publish option, this default profile will be automatically selected for you.

Coming back to dropping object, now I decide I do not want this History table any longer.  Now, I just delete the file from project first.  If I deploy again, I will see that the table is not dropped from target database.  What I need to do now is go to project properties, select Debug menu and check the option called DROP objects in target but not in project.

image

 

Now, let’s publish again.  The table is still there?..  Well, there is one more place I must modify.  I am going to select publish option again, but this time I click Advanced… button.

image

On the following screen I need to check the option called DROP objects in target but not in project one more time. Then, I click on Save As button and re-select the same .publish.xml file to overwrite that profile.

image

Now, I just publish one more time.  Voila, the table is now gone.  The same procedure can be used now to drop all the objects no longer used.

Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *