Last active
January 13, 2023 14:57
-
-
Save renatocfrancisco/3ea81215907fdb9a15a1ad6ce0ebfe8e to your computer and use it in GitHub Desktop.
SQL para encontrar tabelas com certo campo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @Busca VARCHAR(8000) | |
SET @Busca = 'campo' | |
SELECT | |
Colunas.COLUMN_NAME, | |
Tabelas.TABLE_NAME | |
FROM | |
INFORMATION_SCHEMA.TABLES Tabelas | |
INNER JOIN INFORMATION_SCHEMA.COLUMNS Colunas | |
ON Tabelas.TABLE_NAME = Colunas.TABLE_NAME | |
WHERE | |
(Tabelas.TABLE_TYPE='BASE TABLE') AND | |
( | |
(Tabelas.TABLE_NAME LIKE '%' + @Busca + '%') OR | |
(Colunas.COLUMN_NAME LIKE '%' + @Busca + '%') | |
) | |
ORDER BY | |
Tabelas.TABLE_NAME ASC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment