[dba-SQLServer] SQL WildCard Searches

Mark A Matte markamatte at hotmail.com
Tue Jul 25 09:58:40 CDT 2006


Robert,

Thanks for the feedback.  The SQL SERVER db is acutally on my laptop...so I 
didn't think I would need to use MSACCESS to query the data...but for 
me...coding the looping part may be easier in Access.

Also...the with the sample select below I was going to try something 
similar...and have the entire where statement as a seperate string because 
the search is not just for each word...but combinations...and's, or's, and 
stuff...

Thanks again,

Mark A. Matte

>From: "Robert L. Stewart" <rl_stewart at highstream.net>
>Reply-To: dba-sqlserver at databaseadvisors.com
>To: dba-sqlserver at databaseadvisors.com
>CC: markamatte at hotmail.com
>Subject: Re: [dba-SQLServer] SQL WildCard Searches
>Date: Mon, 24 Jul 2006 13:02:03 -0500
>
>Mark,
>
>A stored procedure for each field you want to search.
>
>Something similar to this:
>
>CREATE PROCEDURE uspSearchField1
>      @Word varchar(20)
>AS
>SELECT *
>FROM MyTable
>WHERE TheField LIKE '%' + @word + '%'
>
>You would execute the SP from Access with a pass-through query.
>
>EXEC USPSearchField1 'Looking'
>
>You could store the words in a table and use 2 queries, one without
>the parameter and the second one that you change the SQL statement
>each time using the SQL from the first plus the word from the
>table.  Then you could loop through the table and through all of the
>queries and get all of the matches rather quickly.
>
>Robert
>
>At 12:00 PM 7/24/2006, you wrote:
> >Date: Mon, 24 Jul 2006 16:34:27 +0000
> >From: "Mark A Matte" <markamatte at hotmail.com>
> >Subject: Re: [dba-SQLServer] SQL WildCard Searches
> >To: dba-sqlserver at databaseadvisors.com
> >Message-ID: <BAY121-F18B18BCDBEE8D108735447D2650 at phx.gbl>
> >Content-Type: text/plain; format=flowed
> >
> >Hello All,
> >
> >I am finally getting my data from Informix into SQL Server.  I need to do
> >wild card searches(about 5-7 different key word combinations) on 10
> >different fields.  In Access I planned on having a criteria table, each
> >record being the end of the needed sql statement...and using VBA to loop
> >through these criteria records and executing them against each of the 10
> >fields.
> >
> >Any suggestions as to my best approach in SQL server?
> >
> >Also,  I have to do this 5 more times...same fields...but different set 
>of
> >key words each time, so I was kinda looking for some automation...or at
> >least the easiest way to modify for each new request.
> >
> >Any feedback is appreciated.
> >
> >Thanks,
> >
> >Mark A. Matte
>
>
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com
>





More information about the dba-SQLServer mailing list