• Stamey (7/19/2011)


    My task is to go through certain fields one many DBs and servers to make the columns larger. In this case it is because the standard column size is growing, per HIPAA rules. I need to know if the columns have any dependencies on them that must be removed before we make the field larger. One case would be if the field participates in an index.

    I have already written the necessary TSQL to determine if the column participates in an index or is referenced in a proc, but now I'm thinking of other constraints and am looking for code to determine if the column has any dependencies of any kind on it.

    It seems that sp_Depends will not work in this situation even if it did work reliably (I have been reading it missis things if the objects weren't created in the correct order), as according to BOL, it doesn't do column dependencies.

    The end goal is to take the list of servers, DBs, Schemas, and Columns run them in a temporary table on a given server and generate the necessary scripts to expand the fields as well as drop and recreate any necessary dependent objects along the way.

    I have almost 1400 columns to deal with, which is why I am trying to automate this.

    Thanks,

    Chris

    Let's make a list...I heard:

    - indexes

    - procs

    Brainstorming on other places to look internally:

    - user-defined functions

    - SQLCLR objects

    - column defaults

    - column and table check constraints (may contain length checks or other references)

    - rules (hopefully you're not still using these)

    - indexed views

    - regular views with schemabinding

    - views that manipulate the column length or do string manipulation or that would otherwise care of a length change

    - foreign keys (hopefully none on character-based columns)

    - primary keys (same as fks)

    Externally (is it a concern?):

    - references by remote Linked Servers

    - references by embedded sql in applications

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato