I really like the new feature to quickly filter the databases and tables by name.
Another cool filter would be a filter by column.
Some time happens to ask something like this: "What is the table tha has the column password?" the answere could be "Some tables has it" :).
Is there a way to do something like this? If not, it would be a great feature to implement!
Table filter by column name
The above query also works on SQL Server (>=2005) if you remove the quotes around COLUMNS. However it will only check in the current database (add a suitable USE xyz; to make sure you're in the correct db).
Here's a way to query all tables in all databases:
SET NOCOUNT ON
DECLARE @AllTables table (TABLE_CATALOG sysname,TABLE_SCHEMA sysname, TABLE_NAME sysname, COLUMN_NAME sysname)
DECLARE
@SQL nvarchar(4000)
SET @SQL='SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME FROM [?].information_schema.COLUMNS c WHERE c.COLUMN_NAME LIKE ''%password%'''
INSERT INTO @AllTables (TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME,COLUMN_NAME)
EXEC sp_msforeachdb @SQL
SET NOCOUNT OFF
SELECT * FROM @AllTables ORDER BY TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME,COLUMN_NAME
Here's a way to query all tables in all databases:
SET NOCOUNT ON
DECLARE @AllTables table (TABLE_CATALOG sysname,TABLE_SCHEMA sysname, TABLE_NAME sysname, COLUMN_NAME sysname)
DECLARE
@SQL nvarchar(4000)
SET @SQL='SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME FROM [?].information_schema.COLUMNS c WHERE c.COLUMN_NAME LIKE ''%password%'''
INSERT INTO @AllTables (TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME,COLUMN_NAME)
EXEC sp_msforeachdb @SQL
SET NOCOUNT OFF
SELECT * FROM @AllTables ORDER BY TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME,COLUMN_NAME
Please login to leave a reply, or register at first.