sql使用自身和额外的字符串更新字段

时间:2022-01-11 07:52:36

I am trying to update a field with the contents of itself an added string but it does not work

我尝试用添加的字符串的内容来更新一个字段,但它不起作用。

UPDATE Products_Joined SET Products_Joined.TechSpecs = Products_Joined.TechSpecs + 'test'

Any ideas

任何想法

4 个解决方案

#1


2  

Data type is text

数据类型是文本

If you are on SQL Server 2005 or higher you can cast your text column to varchar(max).

如果您使用的是SQL Server 2005或更高版本,可以将文本列转换为varchar(max)。

UPDATE Products_Joined 
SET TechSpecs = ISNULL(CAST(TechSpecs AS VARCHAR(MAX)), '') + 'test'

#2


2  

that should work, but you might need to remove the table name

这应该是可行的,但是您可能需要删除表名

UPDATE Products_Joined SET TechSpecs = TechSpecs + 'test'

#3


1  

If you want to join two string in SQL use CONCAT as CONCAT (string1,string2) an example: UPDATE Products_Joined SET TechSpecs = CONCAT (TechSpecs ,'test') ;

如果您想在SQL中连接两个字符串,请使用CONCAT作为CONCAT (string1,string2)示例:UPDATE products_join SET TechSpecs = CONCAT (TechSpecs,'test');

#4


0  

Since the column data type is text you cannot do a concatenation with a string since the column TexhSpecs is binary data type(TEXT) .

由于列数据类型是文本,所以不能对字符串进行连接,因为列texhspec是二进制数据类型(文本)。

#1


2  

Data type is text

数据类型是文本

If you are on SQL Server 2005 or higher you can cast your text column to varchar(max).

如果您使用的是SQL Server 2005或更高版本,可以将文本列转换为varchar(max)。

UPDATE Products_Joined 
SET TechSpecs = ISNULL(CAST(TechSpecs AS VARCHAR(MAX)), '') + 'test'

#2


2  

that should work, but you might need to remove the table name

这应该是可行的,但是您可能需要删除表名

UPDATE Products_Joined SET TechSpecs = TechSpecs + 'test'

#3


1  

If you want to join two string in SQL use CONCAT as CONCAT (string1,string2) an example: UPDATE Products_Joined SET TechSpecs = CONCAT (TechSpecs ,'test') ;

如果您想在SQL中连接两个字符串,请使用CONCAT作为CONCAT (string1,string2)示例:UPDATE products_join SET TechSpecs = CONCAT (TechSpecs,'test');

#4


0  

Since the column data type is text you cannot do a concatenation with a string since the column TexhSpecs is binary data type(TEXT) .

由于列数据类型是文本,所以不能对字符串进行连接,因为列texhspec是二进制数据类型(文本)。