• Martin

    Let me see if I can be of a little bit more help. I'm disappointed, but not altogether surprised, that the code you posted is generated by a Microsoft utility. Given that, there's little point in trying to refactor the code, since it will only come out exactly the same next time you press the button.

    You should be able to get the code to work with just a couple of tweaks. If you study the error messages in your original post, you'll notice that the errors are occurring in just two stored procedures. You need to find the definitions for those stored procedures and tweak the table variable declarations thus:

    DECLARE @tbNames table(Name nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL PRIMARY KEY)

    Here I'm making the same assumption that Simon did, namely that SQL_Latin1_General_CP1_CI_AS is your database collation and Latin1_General_CI_AS is the server collation. Once you've changed that line for each of the two offending stored procedures in your script, you can just run it in the normal way.

    One option I didn't suggest before is to build or comandeer a SQL Server instance where the server collation is the same as that of your database, and move everything over.

    John