September 14, 2005 at 12:28 pm
Hi,
I'm pretty new to SQL and from what I understand I can't use the '=' operator on a TEXT object. I get an error if I try to do something like IF (someTEXTobject = @userInput).
Is there any way I can I can check if a user input equals a field that is stored in the database as a TEXT object?
If I use LIKE would it check for an exact match?
Thanks if advance for any help!
September 14, 2005 at 3:28 pm
Hi sc - you could do something like this...example for pubs database...The LIKE will give you all rows that have the @userInput value in them - the '%' being wildcards for a string of 0 - n characters....
DECLARE @userInput VarChar(20) SET @userInput = 'algo' SELECT pr_info FROM pub_info WHERE pr_info like '%' + @userInput + '%'
You should also read BOL on this topic for more specific information...
Retrieving ntext, text, or image Values
**ASCII stupid question, get a stupid ANSI !!!**
September 14, 2005 at 4:07 pm
Sorry, I'm new to this but what is "BOL"?
Could you provide me a link to that topic info?
I really appreciate your help... thanks!
September 14, 2005 at 5:49 pm
sc - sorry to've assumed that everyone knows what BOL is - it's books online - comes with SQL Server - if you don't have it - you could probably find it at the microsoft website...haven't checked out this link yet but see if this is it...
**ASCII stupid question, get a stupid ANSI !!!**
September 15, 2005 at 7:46 am
If you need to make an exact match, just leave off the wildcards.
DECLARE @userInput VarChar(200)
SET @userInput = 'This is sample text data for
Scootney Books, publisher 9952 in the pubs database. Scootney Books is
located in New York City, New York.'
SELECT pr_info
FROM pub_info
WHERE pr_info like @userInput
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy