Scripting Tables with ALTER with dependencies

  • Dear Experts,
    Please advise how I can script all the tables of a database with ALTER option . It should script the drop and create of the dependencies like Indices, Constraints .Thanks in advance.

  • Arsh - Saturday, December 9, 2017 4:25 AM

    Dear Experts,
    Please advise how I can script all the tables of a database with ALTER option . It should script the drop and create of the dependencies like Indices, Constraints .Thanks in advance.

    "It Depends".  What is it that you're trying to ALTER on every table?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden - Sunday, December 10, 2017 4:19 PM

    Arsh - Saturday, December 9, 2017 4:25 AM

    Dear Experts,
    Please advise how I can script all the tables of a database with ALTER option . It should script the drop and create of the dependencies like Indices, Constraints .Thanks in advance.

    "It Depends".  What is it that you're trying to ALTER on every table?

    Hi Jeff. I suppose I would become an automation project actually. Needs kinda data analytics /machine-learning. The script has to read the contents of the column and analyze basing on the Max / Min / Avg values and how the data is distributed and then suggest a length /Type and generate alter command . for each column where applies. On a smaller scale , similar lines ,I'm building something that projects Index Rebuilds/Reorganize for all  objects based on an algorithm (counting number of table cols , Index cols / Row Count etc ) that determines the fill factor .

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

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