user357034
user357034

Reputation: 10981

sql update a field with itself and extra string

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

Upvotes: 3

Views: 12037

Answers (4)

Feryat Figan
Feryat Figan

Reputation: 61

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') ;

Upvotes: 1

Mikael Eriksson
Mikael Eriksson

Reputation: 138960

Data type is text

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

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

Upvotes: 2

praveen
praveen

Reputation: 12271

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

Upvotes: 0

Paul G
Paul G

Reputation: 66

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

UPDATE Products_Joined SET TechSpecs = TechSpecs + 'test'

Upvotes: 2

Related Questions