Search every column in every table in Sybase Database
I was being tasked to do similar task recently. IT is not easy in especially SybaseASE.
Option 1 :
You can write custom tool to BCP out data in files and then grep those files to search for particular text that you want to look for. You can use PERL regex to do as well or use native Unix/Linux commands to parse those files and find the required text that you want to look for.
Option 2 :
Another option (which is not that great - quick and dirty way using TSQL ) that worked for me .
Note: This will take long time (slow and unoptimized) depending on your database size, hardware, workload running on the server as well as database layout.
TEST, TEST and TEST it before hand !!
--- run below script and copy the output and run it in another query window.
set nocount on
declare @searchvalue varchar(255)
select @searchvalue = 'test string to search'---- replace this .. !!
print 'set nocount on'
print 'go'
print 'create table #results (table_name sysname, column_name sysname)'
print 'go&quot;

select
   'insert #results select distinct '''
   + object_name(c.id)
   + ''' as table_name, '''
   + c.name
   + ''' as column_name from '
   + object_name(c.id)
   + ' where '
   + c.name
   + ' LIKE ''%'
   + @searchvalue
   + '%'''
   + char(10)
from
   syscolumns c, sysobjects o
where
   c.usertype in (
-- only look for char, varchar, text etc datatypes as we are not interested in int, datetime etc....
    1
    ,2
    ,18
    ,19
    ,24
    ,25
    ,42
    )
and o.type ='U' -- only user tables we are interested in
and c.id = o.id
and c.length&gt;=datalength(@searchvalue )
--and object_name(c.id) = 'some table if you want to filter'

print 'select * from #results'
print 'go&quot;
go