如何通过T-SQL访问视图命令?

时间:2021-08-26 15:46:26

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

我希望能够以编程方式检索在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).

我虽然ADOX集合与ADODB连接一起使用,但我们可以通过catalog / view / command属性访问它。不幸的是,当通过ADO连接从MS-Access客户端连接到SQL Server时,“views”集合不可用,这是我们的情况(请参阅不能使用带有SQL Server的ADOX Views集合)。

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.

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

1 个解决方案

#1


3  

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

#1


3  

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