Link to home
Start Free TrialLog in
Avatar of lp84
lp84

asked on

T-SQL, SQL Server Help

Hi all,

Bit of SQL help here, i'm really stuck been working on this for a couple hours. No idea why i'm getting an error whenever I run this SQL query, using a text driver through an ODBC connection to query a csv file...

Can anyone see anything wrong with my sql?

select  payee.*,
payee.AHIRDA+'/'+payee.AHIRMO+'/'+payee.AHIRYR AS Date_Of_Hire,
CASE ATRMDA
      WHEN 0 THEN '31/12/2999'
      ELSE payee.ATRMDA+'/'+payee.ATRMMO+'/'+ payee.ATRMYR
END AS Termination_Date
from
ptaagr0999.csv payee

Any help much appreciated.

I keep getting hte following error:

Syntax error(Missing operator) in query expression
'CASE ATRMDA
      WHEN 0 THEN '31/12/2999'
      ELSE payee.ATRMDA+'/'+payee.ATRMMO+'/'+ payee.ATRMYR
END'

Thanks a lot..
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

>using a text driver through an ODBC connection to query a csv file...you cannot do that, the text driver does not support all the MS SQL syntax.you have to load the text file with a plain SELECT * into a local table, and then query from there.this technique is called "staging" ...
Avatar of HugoHiasl
HugoHiasl

Which data type does ATRMDA have?

If it is date and you want to check for NULL you need to use

CASE ATRMDA
      WHEN NULL THEN '31/12/2999'
      ELSE payee.ATRMDA+'/'+payee.ATRMMO+'/'+ payee.ATRMYR
END AS Termination_Date

ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial