Generating Individual If Exists Add Column Scripts

  • How would you use SMO to script out "if exists alter table add" scripts for each column in a table? I prefer that format to the one gigantic Create statement, since it makes it easier to deploy incremental column additions.

    There doesn't appear to be a scripting option to make Table.Script() format its script this way, and the Column class doesn't even have a Script method.

    Regards,

    Chris

  • SMO does not do this. You might possibly be able to generate a CREATE TABLE command and reparse it yourself into ADD COLUMN clauses, but that seems problematic to me.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply