如何查找整个数据库的所有表中的某个字段?

时间:2021-09-21 13:52:32
比如说有一个数据库中有一个字段uuid = 40f128ba-fd52-46a7-9856-622f8cf33d3e,
但是数据库中有上百个表,几乎每个表都有uuid这个字段,怎么样查找出来这个未知表的uuid=40f128ba-fd52-46a7-9856-622f8cf33d3e 的记录呢?

4 个解决方案

#1


sp_MSforeachtable @command1 = "select * from ? where uuid = '40f128ba-fd52-46a7-9856-622f8cf33d3e'"

#2


exec sp_MSforeachtable @command1 = "select * from ? where uuid = '40f128ba-fd52-46a7-9856-622f8cf33d3e'"

#3


exec sp_MSforeachtable @command1 = "select * from ? where uuid = '40f128ba-fd52-46a7-9856-622f8cf33d3e'"
只能返回一百条记录,但是数据库中的表有上百个,系统报错:
The query has exceeded the maximum number of result sets that can be displayed in the results grid. Only the first 100 result sets are displayed in the grid.
请问如何解决?

#4


那就分批查咯

#1


sp_MSforeachtable @command1 = "select * from ? where uuid = '40f128ba-fd52-46a7-9856-622f8cf33d3e'"

#2


exec sp_MSforeachtable @command1 = "select * from ? where uuid = '40f128ba-fd52-46a7-9856-622f8cf33d3e'"

#3


exec sp_MSforeachtable @command1 = "select * from ? where uuid = '40f128ba-fd52-46a7-9856-622f8cf33d3e'"
只能返回一百条记录,但是数据库中的表有上百个,系统报错:
The query has exceeded the maximum number of result sets that can be displayed in the results grid. Only the first 100 result sets are displayed in the grid.
请问如何解决?

#4


那就分批查咯