I am working in Access 2010 and am stuck with a poor table design.
The table has multiple columns that may contain a name I need to find.
ie Company, Company DBA1,Company DBA2,DBA3,DBA4,DBA5 etc... Company DBA12
The best that I have come up with is: (assuming I am looking for jbl)
Select Company ,ClientNumber
From tblClient
Where Company = 'jbl' or DBA1='jbl' or DBA2='jbl'... DBA12='jbl'
While it works it is horribly slow!!!
I have found that if I were able to use SQLServer (which I cannot) I could use a Stored Procedure like this:
BEGIN
SET NOCOUNT ON;
declare @Sql varchar(max)
set @sql =
'select Company ,ClientNumber
from dbo.tblClient
where isnull([Company],'''') + isnull( [Company DBA],'''') + isnull( [Company DBA2],'''') + isnull( [Company DBA3],'''') + isnull( [Company DBA4],'''') + isnull( [Company DBA5],'''') + isnull( [Company DBA6],'''') + isnull( [Company DBA7],'''') + isnull( [Company DBA8],'''') + isnull( [Company DBA9],'''') + isnull( [Company DBA10],'''') + isnull( [Company DBA11],'''') + isnull( [Company DBA12],'''') like ''%'+@Look4+'%''
order by company'
print @sql
exec (@sql)
END
This is quite fast.
So I am wondering if there is away to create a similar query or Stored procedure in MS Access 2010?