User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 427,187 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,205 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 963 | Replies: 1 | Solved
Reply
Join Date: Nov 2007
Posts: 2
Reputation: schismaticus is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
schismaticus schismaticus is offline Offline
Newbie Poster

Question Odd issue with LIKE operator

  #1  
Nov 1st, 2007
Hoping someone can shed some light on this one, using MSSQL 2000,

I have a query like this;

Select T.TransactionRecordClass, T.ClassDetail from [remoteserver].otherdb.dbo.Data T where T.TransactionRecordClass like '10000002%'


which will return around 10000 records in under 1 second.
My issue is that I need to make this part of a function, but as soon as I add parameters/variables, it goes from returning in under 1 second, to 11 minutes!!!


DECLARE @TRC_ID nvarchar (9)
SET @TRC_ID = rtrim('10000002') + '%'

Select T.TransactionRecordClass, T.ClassDetail from [remoteserver].otherdb.dbo.Data T where T.TransactionRecordClass like @TRC_ID



There is a non-clustered index on the 2 fields being returned , and about 77 million records in the table. I have attempted using Index hints, but found they are not allowed on remote queries..... So... any clues????

Thanks in advance for any help
Last edited by schismaticus : Nov 1st, 2007 at 3:51 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Posts: 2
Reputation: schismaticus is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
schismaticus schismaticus is offline Offline
Newbie Poster

Re: Odd issue with LIKE operator

  #2  
Nov 2nd, 2007
Found a solution... the field type of T.TransactionRecordClass is "char" my variable is declared "nvarchar", but if I declare the variable as "char" then the query time is back to < 1 second.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 10:04 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC