• One of the DB's I'm looking at has 188 tables with 2516 columns. Yes I can run during off peak times, but it is actually a replicated Oracle DB, so this DB is for reporting purposes only.

    When I try to run this, I get the following errors,

    Msg 170, Level 15, State 1, Line 3

    Line 3: Incorrect syntax near 'max'.

    Msg 170, Level 15, State 1, Line 4

    Line 4: Incorrect syntax near 'max'.

    Msg 137, Level 15, State 1, Line 16

    Must declare the variable '@sql'.

    Msg 137, Level 15, State 2, Line 20

    Must declare the variable '@final_sql'.

    Msg 137, Level 15, State 1, Line 22

    Must declare the variable '@sql'.

    Msg 137, Level 15, State 2, Line 28

    Must declare the variable '@final_sql'.

    I looked at BOL and the syntax looks correct.

    Thanks again for any help you can supply.

    Wes