Brand new to SQL and cant figure out how replace or delete characters in a string. Ex. my record contains "10015191-BROWN-10.5D" and I want to take out "-BROWN" to leave "10015191-10.5D". I used a select statement to filter out the records I dont want to change with this query, SELECT [ItemCode]
,[ItemType]
,[ItemCodeDesc]
,[ProductLine]
,[PrimaryVendorNo]
FROM [dbo].[CI_Item]
WHERE ProductLine='PPE'
AND PrimaryVendorNo='0000085';
SELECT [ItemCode]
, REPLACE([ItemCode],'-BROWN','') replaced_item_code
,[ItemType]
,[ItemCodeDesc]
,[ProductLine]
,[PrimaryVendorNo]
FROM [dbo].[CI_Item]
WHERE ProductLine='PPE'
AND PrimaryVendorNo='0000085';
1 Like
Is that what you actually want or do you have a whole column of things with 2 dashes and you want to remove "the thing" from between the two dashes and leave just one dash for possibly thousand of rows of data?
1 Like
That worked, i think i trying to do the replace after the where and and clauses. So I assumed it just updated the records but it just produces the result, so can an "update" clause get added to the statement to do the update or do i need to do another statement.
Yes but i just wanted to remove one dash and brown from only records that contain the two filters i stated.
Got it. Thank you for the reply.