# VBForums CodeBank > CodeBank - Other >  "Generate Sql Script" Dependencies Orderer

## MartinSmith

If you use the "Generate Sql Script" wizard in MS SQL to recreate databases then you may well get lots of error messages where it cannot add rows to Sysdepends for stored procedures or simply refuses to create views referencing other views as it tries to create them in the wrong order.

The attached page will take the output from the wizard and search the text for dependencies and re-order the script so they are created in the right order.

NB: Change the file extension from "txt" to "htm" to run it!!

Limitations that I know about (but haven't fixed yet!) are...

1) It does not at the moment cater for UDFs you will need to order these manually if required.
2) If you have comments before the actual "CREATE" statement they may get moved into a different procedure as I am using the CREATE portion to delimit the start of a new procedure.

Despite this I have found it to be an immense time saver so thought it would be worth posting.

If anyone fixes these issues or makes any other improvements please repost it!

----------

