我正在寻找一种方法来获取使用 Sql Server 2019 的任意 sql 查询返回的列的系统名称。以下是一些示例查询和所需的结果:
company: id, name
employee: id, name, companyId
select * from company
| tableName | columnName |
company id
company name
select id as whatever from company
| tableName | columnName |
company id
select e.id, e.name, c.name from employee e join company c on e.companyId = c.id
| tableName | columnName |
employee id
employee name
company name
我无法控制输入查询,它们由最终用户提供。