• Thanks for the code anyway, But I still need a favour.

    The SQL code you gave me has the following errors in Sql Server 2000. They include

    Server: Msg 170, Level 15, State 1, Procedure sp_GetDDL, Line 40

    Line 40: Incorrect syntax near 'max'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 55

    Must declare the variable '@vbCrLf'.

    Server: Msg 195, Level 15, State 1, Procedure sp_GetDDL, Line 63

    'schema_id' is not a recognized function name.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 71

    Must declare the variable '@FINALSQL'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 71

    Must declare the variable '@FINALSQL'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 79

    Must declare the variable '@FINALSQL'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 89

    Must declare the variable '@FINALSQL'.

    Server: Msg 170, Level 15, State 1, Procedure sp_GetDDL, Line 312

    Line 312: Incorrect syntax near 'max'.

    Server: Msg 170, Level 15, State 1, Procedure sp_GetDDL, Line 336

    Line 336: Incorrect syntax near 'APPLY'.

    Server: Msg 156, Level 15, State 1, Procedure sp_GetDDL, Line 353

    Incorrect syntax near the keyword 'FOR'.

    Server: Msg 156, Level 15, State 1, Procedure sp_GetDDL, Line 364

    Incorrect syntax near the keyword 'ORDER'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 385

    Must declare the variable '@CONSTRAINTSQLS'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 390

    Must declare the variable '@INDEXSQLS'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 390

    Must declare the variable '@CONSTRAINTSQLS'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 434

    Must declare the variable '@INDEXSQLS'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 461

    Must declare the variable '@INDEXSQLS'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 462

    Must declare the variable '@vbCrLf'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 467

    Must declare the variable '@CHECKCONSTSQLS'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 468

    Must declare the variable '@CHECKCONSTSQLS'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 481

    Must declare the variable '@FKSQLS'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 483

    Must declare the variable '@FKSQLS'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 496

    Must declare the variable '@RULESCONSTSQLS'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 497

    Must declare the variable '@RULESCONSTSQLS'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 514

    Must declare the variable '@TRIGGERSTATEMENT'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 515

    Must declare the variable '@TRIGGERSTATEMENT'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 522

    Must declare the variable '@TRIGGERSTATEMENT'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 523

    Must declare the variable '@vbCrLf'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 528

    Must declare the variable '@EXTENDEDPROPERTIES'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 529

    Must declare the variable '@EXTENDEDPROPERTIES'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 536

    Must declare the variable '@EXTENDEDPROPERTIES'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 537

    Must declare the variable '@vbCrLf'.

    Server: Msg 137, Level 15, State 2, Procedure sp_GetDDL, Line 543

    Must declare the variable '@FINALSQL'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 548

    Must declare the variable '@FINALSQL'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 549

    Must declare the variable '@FINALSQL'.

    Server: Msg 137, Level 15, State 1, Procedure sp_GetDDL, Line 552

    Must declare the variable '@FINALSQL'.