SQL Server选择包含“%txt”的所有列

时间:2019-06-14 15:49:47

标签: sql sql-server

我有一个名为DataSource的表,我试图找到所有包含'%txt'的列(这只是一个伪数据,我的实际数据库要复杂得多)

我尝试使用like子句检查Parameter列是否具有txt,它确实返回所有在子句中具有txt. But when I use的行以获取列名,什么也不返回。任何帮助将不胜感激。我是从这篇帖子here中引用我的代码的。

Id  Name    Type    Parameter       FacilityColumn      Progress    EmailSent   LastRunDate
1   EPIC-HB File    C:/testdata.txt trans_rev_loc_id    Complete    1           2019-04-25 04:15:00.0000000
2   EPIC-HB File    C:/testdata.txt trans_rev_loc_id    Complete    1           2019-04-25 04:15:00.0000000
3   EPIC-HB File    C:/testdata.txt trans_rev_loc_id    Complete    1           2019-04-25 04:15:00.0000000
4   EPIC-HB File    C:/testdata.txt trans_rev_loc_id    Complete    1           2019-04-25 04:15:00.0000000
5   EPIC-HB File    C:/testdata.txt trans_rev_loc_id    Complete    1           2019-04-25 04:15:00.0000000
6   EPIC-HB File    C:/testdata.txt trans_rev_loc_id    Complete    1           2019-04-25 04:15:00.0000000


select * from dbo.DataSource where '%txt' IN (select name from sys.columns  where  object_id =130099504);

select * from dbo.DataSource where Parameter like '%txt';

0 个答案:

没有答案