? on getting all data before a blank line ?

  • Hi

    I  need to grab all the data from a field BEFORE a blank line

    Its formatted similar to...

    Line1
    Line2
    Line3
    Line4
    (blank line)
    Line5

    So in this case I want
    Line1
    Line2
    Line3
    Line4

    Thanks
    Joe

  • So 
    I can get the first line with  LEFT(e.field, CHARINDEX(CHAR(10),e.field))

    but looking closer at the data

    I need the first 5 lines or the first five carraige return

    Thanks

  • Use PATINDEX to search for two consecutive line terminators.  So the next question is whether your data uses Windows (CrLf), Mac(Cr), or Unix(Lf) line terminators.

    Of course, this assume that the "blank" lines are truly blank rather containing non-printing characters like spaces and tabs.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

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

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