1. <i id='yfuvH'><tr id='yfuvH'><dt id='yfuvH'><q id='yfuvH'><span id='yfuvH'><b id='yfuvH'><form id='yfuvH'><ins id='yfuvH'></ins><ul id='yfuvH'></ul><sub id='yfuvH'></sub></form><legend id='yfuvH'></legend><bdo id='yfuvH'><pre id='yfuvH'><center id='yfuvH'></center></pre></bdo></b><th id='yfuvH'></th></span></q></dt></tr></i><div id='yfuvH'><tfoot id='yfuvH'></tfoot><dl id='yfuvH'><fieldset id='yfuvH'></fieldset></dl></div>

    <legend id='yfuvH'><style id='yfuvH'><dir id='yfuvH'><q id='yfuvH'></q></dir></style></legend>
    1. <small id='yfuvH'></small><noframes id='yfuvH'>

        <bdo id='yfuvH'></bdo><ul id='yfuvH'></ul>
      <tfoot id='yfuvH'></tfoot>

    2. 在 text 或 ntext 数据类型上替换 REPLACE

      alternatives to REPLACE on a text or ntext datatype(在 text 或 ntext 数据类型上替换 REPLACE)

        <bdo id='laE5Z'></bdo><ul id='laE5Z'></ul>

      • <small id='laE5Z'></small><noframes id='laE5Z'>

              <legend id='laE5Z'><style id='laE5Z'><dir id='laE5Z'><q id='laE5Z'></q></dir></style></legend>
                <i id='laE5Z'><tr id='laE5Z'><dt id='laE5Z'><q id='laE5Z'><span id='laE5Z'><b id='laE5Z'><form id='laE5Z'><ins id='laE5Z'></ins><ul id='laE5Z'></ul><sub id='laE5Z'></sub></form><legend id='laE5Z'></legend><bdo id='laE5Z'><pre id='laE5Z'><center id='laE5Z'></center></pre></bdo></b><th id='laE5Z'></th></span></q></dt></tr></i><div id='laE5Z'><tfoot id='laE5Z'></tfoot><dl id='laE5Z'><fieldset id='laE5Z'></fieldset></dl></div>
              • <tfoot id='laE5Z'></tfoot>
                  <tbody id='laE5Z'></tbody>

                本文介绍了在 text 或 ntext 数据类型上替换 REPLACE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我需要更新/替换 datatable.column 中的数据.该表有一个名为 Content 的字段.我正在使用 REPLACE 函数.由于列数据类型是 NTEXT,SQL Server 不允许我使用 REPLACE 函数.

                I need to update/replace the data in datatable.column. The table has a field named Content. I'm using the REPLACE function. Since the column datatype is NTEXT, SQL Server doesn't allow me to use the REPLACE function.

                我无法更改数据类型,因为此数据库是 3rd 方软件表.更改数据类型将导致应用程序失败.

                I can't change the datatype because this database is 3rd party software table. Changing the datatype will cause the application to fail.

                UPDATE [CMS_DB_test].[dbo].[cms_HtmlText] 
                SET Content = REPLACE(Content,'ABC','DEF') 
                WHERE Content LIKE '%ABC%' 
                

                我收到此错误:

                消息 8116,级别 16,状态 1,第 1 行参数数据类型 ntext 对于替换函数的参数 1 无效.

                Msg 8116, Level 16, State 1, Line 1 Argument data type ntext is invalid for argument 1 of replace function.

                • 我可以用 T-SQL 解决这个问题吗?有人有如何阅读和循环的示例吗?
                • 由于这是一次性转换,也许我可以更改为另一种类型,但我担心我会弄乱数据.
                • 有一个主键字段:name: ID - integer - 它是一个身份....所以我也需要考虑这个.也许将 Identity 设置为 N 临时.

                  There is a primary key field: name: ID - integer - it's an identity.... So I need to think about this too. Maybe set the Identity to N temporary.

                  请教如何实现REPLACE功能?

                  Please advise on how to achieve the REPLACE function?

                  大约3000 条语句需要使用新解决方案进行更新.

                  Approx. 3000 statements need to be updated with a new solution.

                  推荐答案

                  IF您的数据不会溢出 4000 个字符并且您使用的是 SQL Server 2000 或兼容性8 级或 SQL Server 2000:

                  IF your data won't overflow 4000 characters AND you're on SQL Server 2000 or compatibility level of 8 or SQL Server 2000:

                  UPDATE [CMS_DB_test].[dbo].[cms_HtmlText] 
                  SET Content = CAST(REPLACE(CAST(Content as NVarchar(4000)),'ABC','DEF') AS NText)
                  WHERE Content LIKE '%ABC%' 
                  

                  对于 SQL Server 2005+:

                  For SQL Server 2005+:

                  UPDATE [CMS_DB_test].[dbo].[cms_HtmlText] 
                  SET Content = CAST(REPLACE(CAST(Content as NVarchar(MAX)),'ABC','DEF') AS NText)
                  WHERE Content LIKE '%ABC%' 
                  

                  这篇关于在 text 或 ntext 数据类型上替换 REPLACE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                SQL query to group by day(按天分组的 SQL 查询)
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
                <i id='lMF8U'><tr id='lMF8U'><dt id='lMF8U'><q id='lMF8U'><span id='lMF8U'><b id='lMF8U'><form id='lMF8U'><ins id='lMF8U'></ins><ul id='lMF8U'></ul><sub id='lMF8U'></sub></form><legend id='lMF8U'></legend><bdo id='lMF8U'><pre id='lMF8U'><center id='lMF8U'></center></pre></bdo></b><th id='lMF8U'></th></span></q></dt></tr></i><div id='lMF8U'><tfoot id='lMF8U'></tfoot><dl id='lMF8U'><fieldset id='lMF8U'></fieldset></dl></div>

              • <tfoot id='lMF8U'></tfoot>
                      <bdo id='lMF8U'></bdo><ul id='lMF8U'></ul>
                          <tbody id='lMF8U'></tbody>

                        1. <small id='lMF8U'></small><noframes id='lMF8U'>

                          <legend id='lMF8U'><style id='lMF8U'><dir id='lMF8U'><q id='lMF8U'></q></dir></style></legend>