954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to add char

Guys,

How to make an scripts if itemnumber have no '-U' then i will place this on the right side while
if there's an exising '-U' then no replacement to be done.

ItemNumber
------------------
P300-4410-DROIDERIS
P300-4110-TOUR
P333-4410-EVO-U
P333-4129-8530PUR-U
P333-4170-9330GRY-U
P333-4110-8350-U

RESULTS:
ItemNumber
------------------
P300-4410-DROIDERIS-U
P300-4110-TOUR-U
P333-4410-EVO-U
P333-4129-8530PUR-U
P333-4170-9330GRY-U
P333-4110-8350-U

Thank you

JOV

jovillanuev
Junior Poster in Training
76 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

If you dont want to filter out just the items that does not have a -U then you can do this. I'm assuming that the '-U' is always at the end.

SELECT CASE WHEN SUBSTRING(ItemNumber, LEN(ItemNumber) - 1, 2) = '-U' THEN ItemNumber ELSE ItemNumber + '-U' END AS MyNewItemNumber
From YOURTABLE
jbisono
Posting Pro in Training
442 posts since May 2009
Reputation Points: 71
Solved Threads: 59
 

Thank you very much for your reply.

jovillanuev
Junior Poster in Training
76 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

Thank again. Its working now.

Regards,

Jov

jovillanuev
Junior Poster in Training
76 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

Thank Again. Its Working.

Regards,

Jov

jovillanuev
Junior Poster in Training
76 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

Don't mention it!!!

jbisono
Posting Pro in Training
442 posts since May 2009
Reputation Points: 71
Solved Threads: 59
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You