Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 replace() on data type ntext - how to?

Author  Topic 

fabianus76
Posting Yak Master

191 Posts

Posted - 2006-05-29 : 17:13:00
Hello guys,

I would like to execute a t-sql query and replace a string by another in all records.

I did this :

UPDATE myTable
SET myColumn = replace(myColumn,'old string','new string')

The error I get is :
Argument data type ntext is invalid for argument 1 of replace function.

Thank you very much for any help!

Regards,
Fabian

my favorit hoster is ASPnix : www.aspnix.com !

nr
SQLTeam MVY

12543 Posts

Posted - 2006-05-29 : 20:10:48
see
http://www.nigelrivett.net/SQLTsql/ReplaceText.html
and
http://www.nigelrivett.net/SQLTsql/ReplaceText2.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

fabianus76
Posting Yak Master

191 Posts

Posted - 2006-05-30 : 06:17:04
Hello nr,

thank you for your help!

I couldn't manage to get it works, so I gave up and did it with a little .NET application :-)

Thanks anyway!

Regards,
Fabian

PS it's a petty that sql-server 2005 did not introduce this functinality

my favorit hoster is ASPnix : www.aspnix.com !
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-05-30 : 06:39:33
quote:
Originally posted by fabianus76

Hello nr,

thank you for your help!

I couldn't manage to get it works, so I gave up and did it with a little .NET application :-)

Thanks anyway!

Regards,
Fabian

PS it's a petty that sql-server 2005 did not introduce this functinality

my favorit hoster is ASPnix : www.aspnix.com !



In 2005 you could use NVARCHAR(MAX) and not have this problem.




CODO ERGO SUM
Go to Top of Page

fabianus76
Posting Yak Master

191 Posts

Posted - 2006-05-30 : 07:46:09
Hello Michael,

you mean that the data type nvarchar makes it possible to use the replace() function?

Thank you for the info!

Regards,
Fabian

my favorit hoster is ASPnix : www.aspnix.com !
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2006-05-30 : 08:00:04
quote:
Originally posted by fabianus76

Hello Michael,

you mean that the data type nvarchar makes it possible to use the replace() function?




Yes.

-------
Moo. :)
Go to Top of Page
   

- Advertisement -