HOW in TSQL

  • Can someone help convert this Access SQL to TSQL. Much appreciated!

    SELECT sfProducts.prodName, grades.GRADE, grades.MATERIAL, grades.ANSI, grades.ISO_RANGE, grades.COATING, grades.GRADE_DESCRIPTION

    FROM grades INNER JOIN

    sfProducts ON grades.mfgID = sfProducts.prodManufacturerId

    WHERE (sfProducts.prodID = 'TTA 100114') AND (INSTR(sfProducts.prodName & ' ', ' ' & grades.GRADE & ' ') > 0)

    Kim

    Regards,
    Kim(Kman)

    www.toocoolwebs.com
  • The basic join should be fine, I think if just change instr to charindex it will work.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • Thanks Andy,

    Changing to

    (CHARINDEX(sfProducts.prodName & ' ', ' ' & grades.GRADE & ' ') > 0)

    I get

    Invalid operator for datatype. Operator equals boolean and datatype equals nvarchar.

    Kim

    Regards,
    Kim(Kman)

    www.toocoolwebs.com
  • John Bell helped out on this. Thanks much for the lesson here.

    SELECT sfProducts.prodName, grades.GRADE, grades.MATERIAL, grades.ANSI, grades.ISO_RANGE, grades.COATING, grades.GRADE_DESCRIPTION FROM grades, sfProducts WHERE sfProducts.prodId = 'PL 01220' AND grades.mfgID = sfProducts.prodManufacturerId AND (CHARINDEX(grades.GRADE + SPACE(1), SPACE(1) + sfProducts.prodName + SPACE(1)) > 0)

    Regards,
    Kim(Kman)

    www.toocoolwebs.com

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply