Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Unanswered: Access to SQL Server Upsize Query Problem

    Hi,

    I have a query written in Jet-SQL which i need to convert to T-SQL as I am upgrading an Access DB to SQL Server 2000.

    Query is:
    SELECT WDF_TBLSKILL.RECID,WDF_TBLSKILL.TECHNOLOGY,Iif(EXI STS(SELECT * FROM WDF_TBLCOMPANY_TBLSKILL_LNK WHERE SKILLID=WDF_TBLSKILL.RECID AND COMPANYID=857),1,0) AS CHOSENSKILL FROM WDF_TBLSKILL ORDER BY WDF_TBLSKILL.TECHNOLOGY ASC;

    It is falling over on the 3rd select item (The Iif statement) which I want to return a 1 if any records are found in the subquery or 0 if they aren't.

    I know Iif is not supported in SQL but can't find anything that seems to do the job.

    Please help!!!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    SELECT WDF_TBLSKILL.RECID
    , WDF_TBLSKILL.TECHNOLOGY
    , case when EXISTS
    (SELECT * FROM WDF_TBLCOMPANY_TBLSKILL_LNK
    WHERE SKILLID=WDF_TBLSKILL.RECID
    AND COMPANYID=857) then 1 else 0 end AS CHOSENSKILL
    FROM WDF_TBLSKILL
    ORDER BY WDF_TBLSKILL.TECHNOLOGY ASC
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2003
    Posts
    2

    thanks

    thanks mate - much appreciated. you've saved me a lot of time and effort.

Posting Permissions

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