SqlDbx Forum


You are not logged in.

#1 2020-02-03 12:55:15


Incorrect view name in "Generate Scripts"

If you rename a view in SQL Server using sp_rename (maybe with SSMS too) the database changes the name in the metadata internal to the db, but the saved sql "code" is not changed to reflect the new name.

SqlDbx, when "Generating Databsae Scripts" in the Tools menu, uses the sql code read from sql server, with the effect of generating a file with the correct name ($NAME), but where the "create view" command within the file incorrectly refers to the old, original name.

This is an issue: if you try to recreate a database from the scripts, you create these views with the old name.

For what I can see, when SSMS does the same operation of extracting the sql code for a view, it uses the internal sql code that defines what the view is doing, but substitutes the "create view" part with new code that uses the correct name of the view: the one recovered from the sys.views metadata table.

SqlDbx should be able to do the same. Another reason to do so is that SqlDbx suggests in the sql script generated a "create" or a "alter" view, depending on the last command that was used to act on the view. Applying the correction shoulod also fix this errant behavior.

I know that this is a problem with SQL Server, but SqlDbx should fix this issue, ad SSMS already does. I think (I hope) that SQL Server fixed this stuupid behavior, but the versioni I am using today, 2010 SP2, still has this issue with the view rename. The version of SqlDbx I am using is 6.02 Professional 64 bit.



Board footer

Powered by FluxBB