Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2010
    Posts
    10

    Unanswered: Query running slow, new to SQL

    I am querying against a big table on a server. Is there a quicker way to run my logic. Below is the sample, I was thinking the way I am calculating the date is making it slow.

    SELECT Distinct[CUSTNO_HH]

    FROM [OrderSummary].[dbo].[tblHORDHD_ORDHDR]
    where 'MID' IN ([INS1_HL]
    ,[INS2_HL]
    ,[INS3_HL])
    and left(partnum_hl, 3) like 'BMC'
    and [DESCRIPTION001_HL] like '%Accu%'
    and [INV_DT_HH] Between GetDate()-366 and GetDate()

    Any help would be appreciated.

  2. #2
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    do you have an index on any of those column(s) that you have in your where clause? Also, keep in mind you are looking for just over a year of data, how many rows would qualify?
    Dave Nance

  3. #3
    Join Date
    Dec 2010
    Posts
    10

    Reply

    Thanks for the reply, only one was indexed but I realzied it didn't like the

    and left(partnum_hl, 3) like 'BMC'

    So I changed it to

    where [partnum_hl] like 'BMC%%%%%%%%%%%%'

    Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •