本文介绍了Management Studio如何保存我的T-SQL注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对SQL Server Management Studio保存视图,存储过程等的注释的方式感到困惑。

I'm confused about the way that SQL Server Management Studio saves the comments of views, stored procedures, etc.

让我们改变一个视图我在ALTER语句之前提出了一些意见:

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


b $ b

当我在Management Studio中运行上面的代码时,我的视图将被更改,并且注释将被保存。如果我后来做一个脚本视图as - > ALTER TO - >

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.

因此,管理Studio如何知道这些注释属于视图?是否与 SET QUOTED_IDENTIFIER ON

So how does Management Studio know that those comments 'belong with' the view? Does it have something to do with SET QUOTED_IDENTIFIER ON?

推荐答案

有关在ALTER VIEW之前的GO和ALTER视图之后的GO之间是

What ever is between the GO before ALTER VIEW and the GO after ALTER View will be saved

Go是一个批处理终止符,所以这两个GO语句之间的一切都是一个批处理,这是发送的

Go is a batch terminator, so everything between those 2 GO statements is a batch, and that is what is sent

这篇关于Management Studio如何保存我的T-SQL注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 03:29