欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SqlServer_查询数据库是否包含某一字段

程序员文章站 2022-06-05 11:29:10
...

查询数据库是否 包含某一字段

SELECT t.name  AS table_name,

SCHEMA_NAME(t.schema_id)AS schema_name,

c.name AS column_name , types.name, c.max_length

FROM sys.tables AS t

INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID

inner join sys.types types on types.system_type_id = c.system_type_id

WHERE c.name LIKE '%inputTime%' or c.name like '%inputTime%'

ORDER BY schema_name, table_name 

Navicat_模糊查询字段对应的表

SELECT * FROM information_schema.COLUMNS WHERE COLUMN_NAME='xxx';


SELECT table_name, column_name FROM information_schema.columns
 WHERE column_name = 'xxx';


SELECT column_name FROM information_schema.columns 
WHERE column_name LIKE '%xxx%' AND TABLE_NAME= 'XXXxxx';

SELECT column_name FROM information_schema.columns 
WHERE column_name LIKE '%xxx%' AND TABLE_NAME= 'XXXxxx' 
AND table_name = 'XXX';