Case statement in DTS Query importing data from excel to table

  • I get an ADO error message when I parse a standard SQL statement in my DTS package that is importing data to a table. Are case statements allowed in the dts query when importing data from an excel spreadsheet?

  • Can you post the SQL statement that is failing?

    -- You can't be late until you show up.

  • SELECT '999' + RIGHT([Temporay ID], 5) AS ID, NULL

    AS [Actual End Date], 'Terminated' AS status, [Actual End Date]

    + 1 AS Start_date, case when [Actual End Date] is NULL then [Proposed end date] else [Actual End Date] END as ACT_TERM

    FROM ['Temporary Employees$']

    WHERE

    ([Actual End Date] IS NOT NULL)

  • You've got quotes inside your name brackets:

    ['Temp..']

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Removing the single quotes dod nit make a diference.

  • As far as I know case functions are allowed in embedded dts queries. What is the error that you are receiving?

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Does [ACTUAL END DATE] exist in the spreadsheet? It looks as if you are creating it in the select statement "NULL as [ACTUAL END DATE] " and trying to reference in the case statement at the same time.

    You are also referencing it in your where clause as "where [ACTUAL END DATE] is not null" while setting it to null in the select.


  • If [ACTUAL END DATE] is an expression, I don't know that you could use an expression as part of a concatenation.. im a little confused by:

    NULL as [ACTUAL END DATE]

Viewing 8 posts - 1 through 7 (of 7 total)

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