MSSQL Error: Parameter data type text invalid solution for parameter 1 of the Replace function _mssql

Source: Internet
Author: User
Tags microsoft sql server microsoft sql server 2005 mssql

But we can solve this problem in a different way. Here's how to analyze the solution.

Data for text or ntext types cannot be string manipulated in a query. The most common use is to treat the text as varchar (when the actual content is less than 8000 bytes) or as a nvarchar (when the actual content is less than 4000 bytes long). But this is not a very good deal. After all, if the content of the text field exceeds 8000, it will be truncated or ignored.
Finally found a way to solve the problem of "parameter data type text is invalid for parameter 1 of the Replace function". Here is an example to illustrate how to deal with.
The syntax is as follows:

Copy Code code as follows:
Update table Set Column=replace (CAST (column as varchar (max)), ' 123′, ' abc '

Explanation:
The table in which is the name, column code the columns in the table that need to be replaced. The purpose of the change statement is to replace all occurrences of 123 in column columns in table tables with ABC.
attached: Introduction to max Type
The Max descriptor is introduced in Microsoft SQL Server 2005. This specifier enhances the storage capabilities of the varchar, nvarchar, and varbinary data types. varchar (max), nvarchar (max), and varbinary (max) are collectively referred to as large value data types. You can use a large value data type to store data that is the maximum of 2^31-1 bytes.
Note:
When the ' large value types out of row ' option for the sp_tableoption stored procedure is set to off, the in-line storage for a large value type is limited to 8,000 bytes. When this option is set to ON, only 16-byte roots are stored in rows. For more information, see sp_tableoption (Transact-SQL).
Large-value data types are similar in behavior to the smaller data types associated with them varchar, nvarchar, and varbinary. This similarity enables SQL Server to store and retrieve large characters, Unicode, and binary data more efficiently.
With a large value data type, SQL Server is used in ways that are not possible with the text, ntext, and image data types in earlier versions of SQL Server. For example, in SQL Server 2005, you can define variables that can store large amounts of data (up to 2^31 bytes of characters, integers, and Unicode data). For more information, see Transact-SQL variables.
The following table describes the relationship between the large value data types and the data types that correspond to them in earlier versions of SQL Server.

large Value data type LOB in previous version
varchar (max) text*
nvarchar (max) ntext*
varbinary (max)

Image

* The SQL Server 6.5 version of the client does not support ntext data types, so nvarchar (max) is not recognized.


Important NOTE:
Use varchar (max), nvarchar (max), and varbinary (max) data types instead of text, ntext, and image data types.
Large-value data types are identical in behavior to the smaller data type varchar (n), nvarchar (n), and varbinary (n) corresponding to them. The following describes the use of large-value data types in specific situations:
A cursor can assign data from a large value data type column returned by FETCH to a local variable because it can define a large value data type variable. For more information, see FETCH (Transact-SQL). Using a large value data type does not affect the enforcement cursor type conversion usage of a cursor.
The UPDATE statement is now supported in blocks. The WRITE () clause is partially updated on the underlying large-value data columns. This is similar to the text-pointer operations, WRITETEXT, and Updatetex that are supported in earlier versions of SQL Server for texts, ntext, image data types. For more information, see UPDATE (Transact-SQL). Triggers support the use of after triggers on large-value data type column references in the inserted and deleted tables. For more information, see CREATE TRIGGER (Transact-SQL).
String functions that have built-in operational characters and binary data have been enhanced to support parameters for large-value data types. These functions include:

Copy Code code as follows:
Col_length
CHARINDEX
PATINDEX
Len
Datalength
SUBSTRING

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.