SQL Query – How to group by a memo field

This week I was writing some SQL queries for a Sybase Advantage database and came across a problem of grouping a memo field. At first I thought the way around this was to SubString() the field with a large limit, I noticed that this worked OK with a range of 1-1000 but caused problems with a range of 1-1500. The best solution I found was to convert the memo to a varchar, here is the snippet of SQL.

Convert(MemoField, SQL_VARCHAR) as ConvertedMemo

This then allows you to group by that field and the query still ran very fast.

Leave a Reply

You must be logged in to post a comment.