Sql-server – My SSMS is bringing wrong object in “Script Stored Procedure as” > “CREATE To” > “New Query Editor Window”

scriptingsql serverssms

When I go to Object Explorer and expand down to Stored Procedures (or Tables), right-click on one of them and choose "Script Stored Procedure / Table as" > "CREATE To" > "New Query Editor Window", it takes a while (becomes unresponsive) and then brings another object (function / table).

If I do the same but choose other action (for instance, "ALTER" for Procedures or "DROP And CREATE") instead of CREATE, it brings the correct object.

It started to behave that way without any clear reason, except for, perhaps, the last SSMS update. I thought I had successfully used CREATE just a few minutes before noticing that error, but later I realized I've used ALTER and not CREATE.

I've tried different databases and even different servers, with the same results. I've already restarted the machine but it didn't change anything. I've also asked a coworker to do the same steps and he didn't get any errors in his machine.

Obs.: It has nothing to do with permissions; it is also happening with my local SQL Express installation (where I have full access).

Is there any template for those script generation? If yes, where are they stored? If not, how can I possibly fix that?

Version information:

Microsoft SQL Server Management Studio = 13.0.16100.1;
Microsoft Analysis Services Client Tools = 13.0.1700.441;
Microsoft Data Access Components (MDAC) = 10.0.14393.0;
Microsoft MSXML = 3.0 6.0;
Microsoft Internet Explorer = 9.11.14393.0;
Microsoft .NET Framework = 4.0.30319.42000;
Operating System = 6.3.14393;

Best Answer

I believe this is what you need. That's a link talking about changing templates in the folder / file location when creating stored procedures. It sounds like someone altered the file.