• some of your dates are not dates...probably blank strings for death date(a reasonable assumption would be not all patients die or get transferred)

    something like this:

    ...

    CASE

    WHEN ISDATE(SUBSTRING(BulkColumn, 41, 8)) =1

    THEN CONVERT(datetime,SUBSTRING(BulkColumn, 41, 8)) ELSE NULL

    END AS deathdate,

    ...

    you'll need to do that for any of the columns that might be empty strings i think.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!