I've searched for a bit but wasn't able to find a specific question on this. How do I obtain all the column names in a table whose names contain a specific string? Specifically, if the column name satisfies like %bal% then I would like to write a query that would return that column name and others that meet that criteria in Sybase.
Edit: The Sybase RDBMS is Sybase IQ.
Updated based on OPs additional comments re: question is for a Sybase IQ database.
I don't have a Sybase IQ database in front of me at the moment but we should be able to piece together a workable query based on IQ's system tables/views:
The easier query will use the system view
SYSCOLUMNS:Or going against the system tables
SYSTABLEandSYSCOLUMN:NOTE: The Sybase ASE query (below) will probably also work since the referenced (ASE) system tables (
sysobjects,syscolumns) also exist in SQL Anywhere/IQ products as a (partial) attempt to provide (ASE) T-SQL compatibility.Assuming this is Sybase ASE then a quick join between
sysobjectsandsyscolumnsshould suffice:For example, let's say we want to find all columns in the
sysobjectstable where the column name contains the string'trig':