Text Search in Access2003/SQL

B

Bobby Childers

I'm in dire need of some assistance if someone can help me. I'm trying to do
a "text" search for the first few letters of a username which will bring up a
listing of everything that begins with those letters.

Here is my SQL code:
SELECT dbo.t_Projects.PID, dbo.t_Projects.ProjectNo,
dbo.t_Projects.ProjectName, dbo.t_Projects.DateStart, dbo.t_Projects.DateDue,
dbo.t_Projects.Description, dbo.t_Projects.Purpose,
dbo.t_ITStaff.LastName
FROM dbo.t_Projects INNER JOIN
dbo.t_ITStaff ON dbo.t_Projects.Leader =
dbo.t_ITStaff.SID
WHERE dbo.t_ITStaff.LastName @@LIKE '%'
ORDER BY dbo.t_Projects.PID

I'm getting an error message with the "@@LIKE '%'. I would really
appreciate any help here.

Thanks
 
D

David Lloyd

Bobby:

I would try it the word LIKE without the "@@." For example:

WHERE dbo.t_ITStaff.LastName LIKE '%'

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I'm in dire need of some assistance if someone can help me. I'm trying to
do
a "text" search for the first few letters of a username which will bring up
a
listing of everything that begins with those letters.

Here is my SQL code:
SELECT dbo.t_Projects.PID, dbo.t_Projects.ProjectNo,
dbo.t_Projects.ProjectName, dbo.t_Projects.DateStart,
dbo.t_Projects.DateDue,
dbo.t_Projects.Description, dbo.t_Projects.Purpose,
dbo.t_ITStaff.LastName
FROM dbo.t_Projects INNER JOIN
dbo.t_ITStaff ON dbo.t_Projects.Leader =
dbo.t_ITStaff.SID
WHERE dbo.t_ITStaff.LastName @@LIKE '%'
ORDER BY dbo.t_Projects.PID

I'm getting an error message with the "@@LIKE '%'. I would really
appreciate any help here.

Thanks
 
B

Bobby Childers

David:

I already tried using LIKE '%' but it brings up all of the records. I need
for users to be able to input the first couple of letters of their last name,
i.e. "ch" or "chi" and the search bring up all names that start with those
letters. I know this is a parameter issue, but I can't figure out how to
setup the parameter.

Thanks
 
D

David Lloyd

Bobby:

If you are using a stored procedure, you can declare an input parameter
(nvarchar, for example), and feed the value of the LIKE string to the WHERE
clause. For example:

Declare @Like nvarchar(15)
Set @Like = 'chi%'
SELECT Name FROM AccountTable
WHERE Name LIKE @Like

This example is not a stored procedure, however it shows you how to give the
input parameter to the LIKE clause.

If you are just using SQL command text, then you can build the LIKE string
from the user input textbox information .

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


David:

I already tried using LIKE '%' but it brings up all of the records. I need
for users to be able to input the first couple of letters of their last
name,
i.e. "ch" or "chi" and the search bring up all names that start with those
letters. I know this is a parameter issue, but I can't figure out how to
setup the parameter.

Thanks
 
B

Bobby Childers

David:

I tried your idea and it worked perfectly. I am using a "stored procedure"
since my queries seemed to not show up when I converted the database to
SQL2000.

Thanks for the help, I really appreciate it.
 
Top