How can I access a view command through T-SQL?

余生颓废 提交于 2019-12-11 05:59:43

问题


I'd like to be able to retrieve programmatically the command strings that generate the views on our 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).

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.


回答1:


Something like this?

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

Marc



来源:https://stackoverflow.com/questions/1393386/how-can-i-access-a-view-command-through-t-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!