gpt4 book ai didi

用于获取表名、 View 和存储过程的 SQL 语句,按模式排序

转载 作者:行者123 更新时间:2023-12-02 01:03:47 26 4
gpt4 key购买 nike

是否有一个 SQL 语句可以列出 MS SQL Server 数据库中所有表、 View 和存储过程的名称(按架构名称排序)?

我想从此列表生成一个 Excel 电子表格,其中包含以下列:架构、类型(表、 View 、存储过程)和名称。

最佳答案

这是您要求的内容:

select 
s.name as [Schema],
o.type_desc as [Type],
o.name as [Name]
from
sys.all_objects o
inner join sys.schemas s on s.schema_id = o.schema_id
where
o.type in ('U', 'V', 'P') -- tables, views, and stored procedures
order by
s.name

关于用于获取表名、 View 和存储过程的 SQL 语句,按模式排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2516173/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com