且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 SQL Server 2008 Management Studio 中获取视图表查询(代码)

更新时间:2022-11-28 07:47:03

在 Management Studio 中,打开对象资源管理器.

In Management Studio, open the Object Explorer.

  • 转到您的数据库
  • 有一个子节点Views
  • 寻找您的观点
  • 选择 Script view as >创建到 >新建查询窗口

大功告成!

如果要从 T-SQL 代码中检索定义视图的 SQL 语句,请使用:

If you want to retrieve the SQL statement that defines the view from T-SQL code, use this:

SELECT  
    m.definition    
FROM sys.views v
INNER JOIN sys.sql_modules m ON m.object_id = v.object_id
WHERE name = 'Example_1'