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)
 SQL LIKE statement to text field from ColdFusion

Author  Topic 

michaelsjudd
Starting Member

1 Post

Posted - 2008-04-14 : 20:27:15
Hi.

Here's my scenario. I am running SQL Server 2000 SP4 on a Windows 2003 Server running IIS 6. Using ColdFusion MX 6.1 Updater version.

I am storing HTML page code (some complete, some just clips) in a text type field.

I need to check to see if someone has already saved that exact code already before. So I do the following query (this is ColdFusion, but should give the idea):

<cfquery name="checkforexisting" datasource="mydatasource">
SELECT smallfieldtogetareturn
FROM MyTable
WHERE MyTextField LIKE '%#mystringoflongdata#%'
</cfquery>

Then to see if it posted:

<cfif checkforexisting.RecordCount GT 0>
do the don't clip optional processing
</cfif>

What is killing me is that it finds the match SOMETIMES. Just not ALL the time. I have tried no percent signs when passing the ColdFusion variable, only one on the right (which has solved these types of problems before).

I have put this into a stored procedure, which seemed to help (?).

I even have resorted to creating a temp table first with the clip, then running a query to retrieve the record that was just put in, and comparing THAT to my primary table (both have text type fields). The reason for this, is that if I write a single page that has just the retrieval of the temp record, and that compare is run, it finds EVERY copy of it in the primary table.

I am not terribly familiar with using large text fields, or dealing with these large pieces of HTML code as something to compare!

If anyone has any ideas, it would be greatly appreciated. Adobe forums said "ask some SQL gurus - we're at a loss".

So, here I am...

Mike
   

- Advertisement -