One query works, another doesnt'

Posted on 2006-07-20
Last Modified: 2008-02-26

This is going to be a hard question to answer as you dont have access the the server, but I have some very strange behaviour going on. I really need some trouble shooting tips to help me diagnois the problem:

The Problem:

This works:

SELECT     *
FROM         dbo.SmartPart
WHERE     CONTAINS(Description, 'A2101010') OR
                      CONTAINS(CPC_Code, 'A2101010') OR
                      CONTAINS(pkg_type, 'A2101010')

But this doesn’t

SELECT     *
FROM         dbo.SmartPart
WHERE     CONTAINS(Description, 'A2104011') OR
                      CONTAINS(CPC_Code, 'A2104011') OR
                      CONTAINS(pkg_type, 'A2104011')

Both the records are there and both have data in them, one returns a result, one doesn't and I have no idea where to start

The data fields coppied directly from enterprise manager:

      A2101010      R 1K58 1% 0603 1      1.58      KO      2KO      1%      1%      0.1      W      RES0603      1.55 mm      .85 mm      .45 mm      res      RES0603      0603      Yes      R_1K58_1%_0603_1      Yes      \\\users\Smartpart\SmartPartData\CPC_Codes\A21\A2101\A2101010\PDF\A2101010.pdf      DX Designer      No      Chip_Resistor      Vishay.                              CRCW_0603_1581_F_100                                                  Pending      Pending      Pending      Pending      Pending       

      A2104011      R 1K58 1% 0603 1      1.58      KO      2KO      1%      1%      0.1      W      RES0603      1.55 mm      .85 mm      .45 mm      res      RES0603      0603      Yes      R_1K58_1%_0603_1      Yes      \\\users\Smartpart\SmartPartData\CPC_Codes\A21\A2101\A2101010\PDF\A2101010.pdf      DX Designer      No      Chip_Resistor      Vishay.                              CRCW_0603_1581_F_100                                                  Pending      Pending      Pending      Pending      Pending       
Question by:bhermer
  • 4
  • 2

Author Comment

ID: 17144852
Table Design, should it help

3      CPC_Code      varchar      16      0
0      Description      varchar      255      1
0      Electrical_Value      float      8      1
0      Electrical_Unit      varchar      50      1
0      [Value]      varchar      50      1
0      Tol_Plus      varchar      50      1
0      Tol_Minus      varchar      50      1
0      Rating      float      8      1
0      Rating_Unit      varchar      50      1
0      Package_Style      varchar      50      1
0      Body_Length      varchar      50      1
0      Body_Width      varchar      50      1
0      Body_Height      varchar      50      1
0      Symbol      varchar      250      1
0      pkg_type      varchar      70      1
0      Device      varchar      50      1
0      Web_Page      varchar      250      1
0      InPads      varchar      50      1
0      PadsName      varchar      50      1
0      Fitted      varchar      50      1
0      Datasheet_Path      varchar      250      1
0      Tool      varchar      50      1
0      RC      varchar      50      1
0      ComponentType      varchar      50      1
0      Mnf_1      varchar      50      1
0      Mnf_2      varchar      50      1
0      Mnf_3      varchar      50      1
0      Mnf_4      varchar      50      1
0      Mnf_5      varchar      50      1
0      Mnf_1_PartNum      varchar      100      1
0      Mnf_2_PartNum      varchar      100      1
0      Mnf_3_PartNum      varchar      100      1
0      Mnf_4_PartNum      varchar      100      1
0      Mnf_5_PartNum      varchar      100      1
0      Mnf_1_Web      varchar      100      1
0      Mnf_2_Web      varchar      100      1
0      Mnf_3_Web      varchar      100      1
0      Mnf_4_Web      varchar      100      1
0      Mnf_5_Web      varchar      100      1
0      Mnf_1_App      varchar      50      1
0      Mnf_2_App      varchar      50      1
0      Mnf_3_App      varchar      50      1
0      Mnf_4_App      varchar      50      1
0      Mnf_5_App      varchar      50      1
0      Preferred      varchar      50      1
LVL 12

Expert Comment

ID: 17144859
why don't you use like '%A2104011%' and see if this makes any difference? or are you actually using text search?

Author Comment

ID: 17144909
We have created the algorithums for searching and they are pretty bug free and complex, we cannot start changing them (My manager would freak out!), The CONTAINS has been working for over2 years, the only difference now is the way we input the data into the SQL box, we were using a vb recordset, ie. rs.addnew, rs.update. We have now bought a third party library tool which is creating them with,I presume INSERT statements.

When I run this in enterprise manager I get both records returned:

SELECT     *
FROM         dbo.SmartPart
WHERE     (CPC_Code = 'A2101010') OR
                      (CPC_Code = 'A2104011')
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

LVL 142

Accepted Solution

Guy Hengel [angelIII / a3] earned 500 total points
ID: 17144939
I assume that the full-text index has not been updated since the insert of the record that does not get returned.
check the schedule of the full-text catalog update
LVL 12

Expert Comment

ID: 17144941
if you get it right from query analyzer or enterprise manager then your problem should be in your code or the library that you are talking about... not much help I can provide there!

Author Comment

ID: 17144963
My Guess is that AngelIII is right, dont I feel like an idiot!, trouble is we are installing this new software for the first time today and have desperatly been trying to test it, not realizing the indexing wont happen until midnight tonight! I will see if I can get my Server admin team to initiate an index, if not I will test again tomorrow and (Hopefully) award points to AnglelIII


Author Comment

ID: 17145328
Thanks alot, yes it was the indexing, and yes I am an idiot for not realizing.

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now