smoothcat11
asked on
Concatenate SQL Records with UPDATE
Hello, I'm using SQL Server 2005 and I want to update the name in over 18000 records
I want it to be: name (size) instead of name:
example:
Vitamin A (60 Caps)
right now its:
Vitamin A
Update b
Set b.Name = b.Name' ('a.Size)'
From Product b, newproducturlinfo a
WHERE b.SKU LIKE a.UPC AND b.ProductID = 32167
I keep getting this:
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near ' ('.
I'm using ProductID = 32167 because I don't want to affect more then 1 record if it goes wrong. Any info will help. Thanks
I want it to be: name (size) instead of name:
example:
Vitamin A (60 Caps)
right now its:
Vitamin A
Update b
Set b.Name = b.Name' ('a.Size)'
From Product b, newproducturlinfo a
WHERE b.SKU LIKE a.UPC AND b.ProductID = 32167
I keep getting this:
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near ' ('.
I'm using ProductID = 32167 because I don't want to affect more then 1 record if it goes wrong. Any info will help. Thanks
ASKER
Msg 402, Level 16, State 1, Line 1
The data types nvarchar and ntext are incompatible in the add operator.
Just got this.
They are ntext
The data types nvarchar and ntext are incompatible in the add operator.
Just got this.
They are ntext
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
update b
set b.Name = b.Name + ' (' + cast(a.Size as nvarchar) + ')'
from dbo.Product b
inner join dbo.newproducturlinfo a
on b.SKU like a.UPC
where
b.ProductID = 32167
set b.Name = b.Name + ' (' + cast(a.Size as nvarchar) + ')'
from dbo.Product b
inner join dbo.newproducturlinfo a
on b.SKU like a.UPC
where
b.ProductID = 32167
Your concatenation was wrong.
And changed the join syntax
HTH
David
Open in new window