SQL Replace not working with Text columns

by dotnetpete 19. December 2008 09:43

An annoying limitation of the SQL Server REPLACE function is that it doesn't operate on TEXT data type columns. The CAST function does however. With SQL Server 2005 you can set the size to "MAX" otherwise 2000 and lower you'll have to specify "8000".

REPLACE(CAST(TextColumn as VARCHAR(MAX)), 'find text', 'replace text') 

I did find another solution on the SQL Team site here.

Tags:

Add comment




biuquote
Loading