Management Studio 如何知道保存我的 T-SQL 注释?

发布于 2024-11-07 13:08:48 字数 644 浏览 4 评论 0原文

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

假设我正在更改视图,并在 ALTER 语句之前添加一些注释:

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

当我在 Management 中运行上述代码时工作室,我的观点将被改变,评论将被保存。如果我稍后执行 Script View As -->更改为 -->新的查询窗口,评论将重新出现。

那么 Management Studio 如何知道这些评论“属于”视图呢?它与SET QUOTED_IDENTIFIER ON有关吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖上得阳光 2024-11-14 13:08:48

ALTER VIEW 之前的 GO 和 ALTER View 之后的 GO 之间的内容都将被保存

Go 是批处理终止符,因此这 2 个 GO 语句之间的所有内容都是批处理,这就是发送的内容

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

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

安穩 2024-11-14 13:08:48

它不是 Management Studio,而是 sql server 本身。

无论您在服务器中创建什么(索引、SP,等等),sql server 都会保存您用于创建对象的文本。

It's not management studio but sql server it self

Whatever you create in your server (index, SP, whatever), sql server will save the text you used to create the object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文