如何通过T-SQL访问视图命令? [英] How can I access a view command through T-SQL?

查看:93
本文介绍了如何通过T-SQL访问视图命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够以编程方式检索在我们的SQL Server上生成视图的命令字符串.

I'd like to be able to retrieve programmatically the command strings that generate the views on our SQL Server.

尽管我将ADOX集合与ADODB连接一起使用,但允许我们通过catalog/view/command属性访问它.不幸的是,当通过ADO连接从MS-Access客户端连接到SQL Server时,视图"集合不可用,这就是我们的情况(请参见

I though the ADOX collection, used together with an ADODB connection, will allow us to access this through the catalog/view/command property. Unfortunately, the 'views' collection is not available when connecting from an MS-Access client to a SQL Server through an ADO connection, which is our case (see Cannot Use ADOX Views Collection with SQL Server).

我希望我现在可以找到此问题的T-SQL替代方案.然后,我将能够通过ADO连接发送T-SQL指令,并在客户端收集相应的文本字符串.

I hope I could now find a T-SQL alternative to this problem. I will then be able to send the T-SQL instruction through my ADO connection, and collect the corresponding text string on my client side.

推荐答案

像这样吗?

SELECT
    v.name,
    m.definition
FROM 
    sys.views v
INNER JOIN 
    sys.sql_modules m ON v.object_ID = m.object_id

马克

这篇关于如何通过T-SQL访问视图命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆