---- 全库查询字段Start DECLARE @columnName SYSNAME = 'F_QAZX_COMBO1'; -- 替换为你想查询的字段名 DECLARE @sql NVARCHAR(MAX); SELECT @sql = ISNULL(@sql + ' UNION ALL ', '') + 'SELECT ''' + t.name + '|' + c.name + ''' AS [Table.Column], ' + ' ' + QUOTENAME(c.name) + ' FROM ' + QUOTENAME(t.name) FROM sys.columns c INNER JOIN sys.tables t ON c.object_id = t.object_id WHERE c.name = @columnName and t.name like '%T_SAL%'; ---特定查询某表 EXEC sp_executesql @sql; ---- 全库查询字段End
本文为宁若水!原创文章,转载无需和我联系,但请注明来自[若水]博客 www.lalaya.net