Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query Help 'LKE'

Author  Topic 

bulubuk1976
Starting Member

24 Posts

Posted - 2008-03-10 : 05:31:37
I am using SQL 2000 and I am not getting the right results to my query. I want to do a query that looks or a certain word in a varchar of more than 2000 characters. Here's my code:

SELECT *
FROM Employees
Where JobDescription1 Like '%monthly'

It does pull up records with the word monthly and also pulls a record with empty field which, I am trying to figure out what the code should be.

Thanks for the help and more power!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-10 : 05:35:46
Your query above only pulls the records what ENDS with the text "monthly".



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

bulubuk1976
Starting Member

24 Posts

Posted - 2008-03-10 : 05:48:07
quote:
Originally posted by Peso

Your query above only pulls the records what ENDS with the text "monthly".



E 12°55'05.25"
N 56°04'39.16"




Sorry I mistyped it. Here is the actual code that I am using but still includes Names with blank JobDescription1 in the results. Any Ideas?

SELECT Name, JobDescription1
FROM Employees
Where JobDescription1 Like '%monthly%'
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-10 : 06:18:27
Blank (empty space), or NULL?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-10 : 06:19:48
[code]DECLARE @Sample TABLE (d VARCHAR(200))

INSERT @Sample
SELECT '' UNION ALL -- Empty space
SELECT NULL UNION ALL -- NULL
SELECT 'Bimonthly report' -- Actual text

SELECT *
FROM @Sample
WHERE d LIKE '%monthly%'[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -