I'm confused about the way that SQL Server Management Studio saves the comments of views, stored procedures, etc.
Let's say I'm altering a view and I put some comments in before the ALTER statement:
USE [SomeDatabase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- Let's add some comments about this view!
ALTER VIEW [dbo].[MyView]
AS
SELECT Stuff
FROM TableOfStuff
-- To get the other stuff, we have to do an inner join
INNER JOIN OtherStuff
ON TableOfStuff.OtherKey = OtherStuff.StuffKey
GO
When I run the above code in Management Studio, my view will be altered AND the comments will be saved. If I later do a Script View As --> ALTER TO --> New Query Window
, the comments will reappear.
So how does Management Studio know that those comments 'belong with' the view? Does it have something to do with SET QUOTED_IDENTIFIER ON
?