This is the error I get when running this
Server: Msg 170, Level 15, State 1, Line 13
Line 13: Incorrect syntax near 'max'.
Server: Msg 195, Level 15, State 1, Line 32
'OBJECT_SCHEMA_NAME' is not a recognized function name.
Server: Msg 137, Level 15, State 1, Line 46
Must declare the variable '@object_id'.
Server: Msg 137, Level 15, State 1, Line 53
Must declare the variable '@AddLine'.
Server: Msg 137, Level 15, State 1, Line 55
Must declare the variable '@DropLine'.
Server: Msg 137, Level 15, State 1, Line 56
Must declare the variable '@AddLine'.
Server: Msg 137, Level 15, State 1, Line 58
Must declare the variable '@AddLine'.
Server: Msg 137, Level 15, State 1, Line 60
Must declare the variable '@AddLine'.
Server: Msg 137, Level 15, State 1, Line 61
Must declare the variable '@DropLine'.
Server: Msg 137, Level 15, State 1, Line 70
Must declare the variable '@parent_object_id'.
Server: Msg 137, Level 15, State 1, Line 75
Must declare the variable '@fkline'.
Server: Msg 137, Level 15, State 1, Line 77
Must declare the variable '@pkline'.
Server: Msg 137, Level 15, State 1, Line 83
Must declare the variable '@fkline'.
Server: Msg 137, Level 15, State 1, Line 84
Must declare the variable '@pkline'.
Server: Msg 137, Level 15, State 1, Line 89
Must declare the variable '@fkline'.
Server: Msg 137, Level 15, State 1, Line 90
Must declare the variable '@pkline'.
Server: Msg 137, Level 15, State 1, Line 97
Must declare the variable '@AddLine'.
Server: Msg 137, Level 15, State 1, Line 99
Must declare the variable '@AddLine'.
Server: Msg 137, Level 15, State 1, Line 100
Must declare the variable '@AddLine'.
Server: Msg 137, Level 15, State 1, Line 102
Must declare the variable '@AddLine'.
Server: Msg 137, Level 15, State 1, Line 122
Must declare the variable '@DropScript'.
Server: Msg 137, Level 15, State 1, Line 123
Must declare the variable '@DropLine'.
Server: Msg 137, Level 15, State 1, Line 123
Must declare the variable '@AddScript'.
Server: Msg 137, Level 15, State 1, Line 125
Must declare the variable '@AddLine'.
Server: Msg 137, Level 15, State 1, Line 125
Must declare the variable '@object_id'.
Server: Msg 137, Level 15, State 1, Line 135
Must declare the variable '@DropScript'.
Server: Msg 137, Level 15, State 1, Line 135
Must declare the variable '@AddScript'.
¤ §unshine ¤