get partial text data from a text field

  • hi,

    I wanna get partial text data from a text field. say first 100 characters from it. So i can list the partial text in a grid.

    Any ideas.

     

  • thanks

  • SELECT

    LEFT(MyCol, 100) as LeftVal

    SUBSTRING(MyCol, 1, 100) as SubStrVal

    FROM MyTable

  • Note that if it genuinely is a column of type 'text' (as opposed to varchar), the left function will error. In that case, you can use cast instead.

    declare @t table (TextColumn text, VarcharColumn varchar(800))

    insert @t select 'fsdkjasdlkjfljsfdfklsjsfalasfjdfsda', 'fsdkjasdlkjfljsfdfklsjsfalasfjdfsda'

    select cast(TextColumn as varchar(10)), left(VarcharColumn, 10) from @t

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • details, details...

Viewing 5 posts - 1 through 4 (of 4 total)

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