怎么对字段名进行模糊查询

2024-12-28 06:25:28
推荐回答(1个)
回答1:

给你个例子是SQL的

SELECT DISTINCT
'select ' + STUFF(( SELECT ',' + name
FROM sys.columns t
WHERE object_id = sys.columns.object_id AND name LIKE 'a%' --字段名起始字符
FOR
XML PATH('')
), 1, 1, '') + ' from ' + OBJECT_NAME(object_id)
FROM sys.columns
WHERE object_id = OBJECT_ID('TT')