Table filter by column name

[expired user #7050]'s profile image [expired user #7050] posted 11 years ago in Feature discussion Permalink
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!
[expired user #7050]'s profile image [expired user #7050] posted 11 years ago Permalink
sorry for the big amount of grammatical errors unhappy
ansgar's profile image ansgar posted 11 years ago Permalink
There is a simple query you can fire against the information_schema database:

SELECT * FROM information_schema.`COLUMNS` c
WHERE c.COLUMN_NAME LIKE '%password%'
[expired user #7050]'s profile image [expired user #7050] posted 11 years ago Permalink
i'm connected to a SQLServerhappy
[expired user #7068]'s profile image [expired user #7068] posted 11 years ago Permalink
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
[expired user #7050]'s profile image [expired user #7050] posted 11 years ago Permalink
great! anyway, I think it would be a usefull, and cheap to implement, feature. Don't you?
ansgar's profile image ansgar posted 11 years ago Permalink
This is not something I will put into HeidiSQL as a new feature. The above hints were meant to help you out for finding the wanted column by firing a query.
[expired user #9484]'s profile image [expired user #9484] posted 8 years ago Permalink

I vote for this feature. I think on table view in "Data" should be dynamic filter for column name that I can use to fast filter columns. I know there is filter for column but in this case it is unusefull

[expired user #11644]'s profile image [expired user #11644] posted 6 years ago Permalink

Nice feature, but for MSSQL: SELECT * FROM INFORMATION_SCHEMA.COLUMNS c WHERE c.COLUMN_NAME LIKE '%password%'

Please login to leave a reply, or register at first.