SQL根據列值查詢表

select distinct
'select distinct ''' + tab.name + '.' + col.name
+ '''    from [' + tab.name
+ '] where [' + col.name + '] like ''%電話呼叫%'' union '
from sys.tables tab
join sys.columns col on (tab.object_id = col.object_id)
join sys.types types on (col.system_type_id = types.system_type_id)
where tab.type_desc ='USER_TABLE'
and types.name IN ('CHAR', 'NCHAR', 'VARCHAR', 'NVARCHAR');
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章