0
SELECT  LM.LocationName ,
        PPD.RegistrationNo ,
        ISNULL(PPD.Title, '') + ' ' + ISNULL(PPD.FirstName, '') + ' '
        + ISNULL(PPD.LastName, '') AS CustomerName ,
        PPD.RegistrationDate ,
        PPD.Ref_By_Patient ,
        ISNULL(PPD1.Title, '') + ' ' + ISNULL(PPD1.FirstName, '') + ' '
        + ISNULL(PPD1.LastName, '') AS Ref_By_PatientName ,
        PPD.Mobile ,
        PPD.Res_Telephone ,
        PPD.Off_Telephone ,
        PPD.EMail ,
        KB.KwnBy ,
        RTM.RegType ,
        PPD.Street ,
        AM.area_name ,
        CM.city_name ,
        DM.DoctorName ,
        PPD.SpecialDiscount ,
        PPD.SpecialDisPercentage ,
        PPD.ServiceDisPercentage ,
        PPD.Type ,
        PPD.TypeChangedDate
FROM    Patient_Personal_Details PPD ,
        LocationMaster LM ,
        KnownBy KB ,
        Area_Master AM ,
        RegTypeMaster RTM ,
        City_Master CM ,
        Doctor_Master DM ,
        Patient_Personal_Details PPD1
WHERE   PPD.Loc_Id = LM.LocationCode
        AND PPD.Knownby*=CAST(KB.Knwid AS VARCHAR(25))
        AND PPD.Area*=AM.area_id
        AND PPD.City*=CM.city_id
        AND PPD.Doctorname*=DM.Doctor_Id
        AND PPD.RegTypeId*=RTM.RegTypeId
        AND PPD.Ref_By_Patient*=PPD1.RegistrationNo
        AND PPD.RegistrationDate >= '01-Oct-2013'
        AND PPD.RegistrationDate <= '10-Dec-2013'
ORDER BY LM.LocationName ,
        PPD.RegistrationNo

Error

Incorrect syntax near '*='.

Please advise

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user3085553
  • 63
  • 3
  • 4
  • 5
    it hurts my eyes. ouch. – Raptor Dec 10 '13 at 06:16
  • 1
    why are you using that operator? You are multipying IDs! – juergen d Dec 10 '13 at 06:17
  • 5
    [Bad habits to kick : using old-style JOINs](https://sqlblog.org/2009/10/08/bad-habits-to-kick-using-old-style-joins) - that old-style *comma-separated list of tables* style was discontinued with the ANSI-**92** SQL Standard (more than **20 years** ago). And that includes the `=*` and `*=` operators - stop using those **RIGHT NOW** and switch to the proper `JOIN` syntax, and all your problems will magically go away .... – marc_s Dec 10 '13 at 06:25

1 Answers1

5

*= was used as a shortcut syntax for left outer join, whereas =* was a shortcut for a right outer join. Instead of using the left outer join tablex on x.col1 = ... syntax, those join fields are being listed in the where clause. Personally, I'd migrate away from joining in the where clause.

What is this operand (*= star-equals) in SQL server 2000?

Maybe this was removed in 2012? try changing the database compatibility mode back one version to 9 (2005) or 10 (2008).

Community
  • 1
  • 1
ps2goat
  • 8,067
  • 1
  • 35
  • 68