April 24, 2012 at 2:11 pm
I have a table as below:
MEMBERID INT
SEQUENCE INT
NOTES TEXT
I need a script to:
select MEMBERID, max(SEQUENCE) and NOTES
But, text data will not take group function.
How to fix it?
April 24, 2012 at 2:19 pm
No promises, try casting the NOTES column to varchar(max) in the select list, CAST(NOTES as VARCHAR(MAX)) as NOTES.
April 24, 2012 at 2:20 pm
The real fix is to not use the text data type. It is deprecated. Use (n)varchar instead.
A workaround to your immediate problem would be to CAST() your TEXT field as VARCHAR:
select
MEMBERID,
max(SEQUENCE),
cast(NOTES as varchar(128))
from TestTextTable
group by MEMBERID, cast(NOTES as varchar(128))
You also need to determine if you want to group by NOTES as well (I assumed so in my query). If not, determine how you want it aggregrated.
April 24, 2012 at 2:29 pm
Cast is working.
Thanks
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply