x

Looping query

Could you please look at this cript and tell me what I am not doing because it's looping and the output is incorrect. Using SQL server 2008 R2

 SELECT A.BATDAT, A.BATSEQ,A.SEQNBR, A.BILTP2, A.BILTP3,A.RCPDAT,A.DIAGN1,A.POSCOD,
 B.FSTNAM, B.LSTNAM, B.NPI_NUMBER, C.REVCOD
 FROM UMCFIL A, PHYFIL B, UMCDTL C
 WHERE (BILTP2 = '9' and BILTP3 = '9') OR (BILTP2 = '3' and BILTP3 = '1')
 AND A.BATDAT=C.BATDAT
 AND A.BATSEQ=C.BATSEQ
 AND A.SEQNBR=C.SEQNBR
 and RCPDAT BETWEEN '01/01/2015' AND '3/31/2015'
more ▼

asked Jan 09 at 05:23 PM in Default

avatar image

khan16
10 3

There isn't a loop present within the query. It's just a direct SELECT query. What results were you expecting? Do you want it to loop?

Jan 09 at 07:02 PM JohnM

No i dont want it to loop. It's taking a long compilation time given the table size so i thought something may be wrong with the joins.

Jan 09 at 07:04 PM khan16

The way you have the joins is from an older syntax. It's more appropriate now (ANSI compliant and all) to use the INNER JOIN syntax to accommodate the joins. Note that either way should deliver the same results however. If the tables are larger it could take time to produce results. Your best best would be to post an execution plan so that we can see what might be occurring under the hood.

Jan 09 at 07:15 PM JohnM
(comments are locked)
10|1200 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x77

asked: Jan 09 at 05:23 PM

Seen: 30 times

Last Updated: Jan 09 at 07:15 PM

Copyright 2016 Redgate Software. Privacy Policy