Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSMS removing pre-BEGIN comments from my stored procedures

I'm running SSMS 12.0.2000.8

If I use the SSMS query editor to create a stored procedure (such as the one below) the comments before BEGIN are removed when I execute/save it:

CREATE PROCEDURE myproc
/* Say goodbye to this comment */
    @var1 int -- this comment will disappear too
AS
BEGIN
   /* This comment is safe */
   select 'hello' -- this too shall endure
END

A colleague is running the same version of SSMS and has no such problems. If I execute one of his scripts using sqlcmd.exe the comments get stripped then too. I presume there must be a global setting that I need to change but I have no idea where it might be.

like image 514
Gary Chapman Avatar asked Jan 18 '26 16:01

Gary Chapman


2 Answers

I was experiencing the same issue and found that it was caused by Tools -> Options -> SQL Server Object Explorer -> Scripting -> Convert user-defined data types to base types.

When this is "True" I lose my comment blocks. When "False" my comment blocks came back.

like image 117
nil_jones_pdx Avatar answered Jan 21 '26 08:01

nil_jones_pdx


After observing some other strangeness (namely with execute as caller being added to my scripts), I did some Googling and discovered the answer:

delete \Users\[user]\AppData\Roaming\Microsoft\SQL Server Management Studio\12.0\sqlstudio.bin

WARNING: You will lose your current list of memorized SQL Servers/usernames/passwords.

like image 39
Gary Chapman Avatar answered Jan 21 '26 09:01

Gary Chapman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!