给你个例子是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')