We allow our uses to alter certain views for reports and what not based on some application field meta data that we keep track of in our application. These fields can be created at run time. I have a standard process in place to alter the views when a field is added or removed. I now need to do this programmatically however, which means I need to be able to pull the current Alter view script, make my modifications, and then execute it against the database. The last two steps are easy enough, but the first part is giving me some trouble.
Design decisions aside (as they are out of my hands in this particular instance). I would like to know how to retrieve the Alter view script that Sql server management studio uses for the View->Edit command.
I require the exact same output as that command because I have comment hooks in my scripts that allow my edits to occur.
Related questions, but not quite what I am looking for.
In MSSQL, how do I generate a CREATE TABLE statement for a given table?