有没有一种语法可以让我从不同的数据库中获取表的列?我尝试使用 select column_name from information_schema.columns
where table_name = 'Database_Name.DBO.Table_Name'
但它不起作用。请帮帮我,这几天一直在这样做。
最佳答案
你很接近。 TABLE_NAME 只是表的名称。其余信息在 TABLE_CATALOG 和 TABLE_SCHEMA 中。您可以使用要从中选择的目录来限定 information_schema:
select column_name from Database_Name.information_schema.columns
where table_name = 'Table_Name' AND table_schema = 'dbo'
关于sql-server - 从不同的数据库中获取表的所有列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27895034/