Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 updating cells in a table - please help

Author  Topic 

tchelcho
Starting Member

4 Posts

Posted - 2008-06-18 : 12:27:10
I have two questions. I am somewhat of a novice at this but would really appreciate some help.

Table = svc
There are multiple columns but I just need adjustments in the first 2.

Current Table:
code name svctype
CTS0003 CT Abd Ltd 51608
CTS0005 CT Abd W Cont 51608
CTS0011 CT Abd WWO Cont 51608
CTS0013 CT Abd WO Cont 51608
CTS0023 CT Abd-Ltd Pel W Cont 51608
CTS0025 CT Abd-Ltd Pel WO Cont 51608

What I want it update it to:
code name svctype
RCT0003 AR CT Abd Ltd 19254
RCT0005 AR CT Abd W Cont 19254
RCT0013 AR CT Abd WO Cont 19254
RCT0011 AR CT Abd WWO Cont 19254
RCT0023 AR CT Abd-Ltd Pel W Cont 19254
RCT0025 AR CT Abd-Ltd Pel WO Cont 19254

QUESTION #1:
So I am trying to figure out if I could write a statement that basically updates the CODE column’s first three letters in each cell from CTS to RCT and retains the numbers afterwards.


QUESTION #2
The NAME column in Table 1 would also need a little adjustment.
I need to add AR in front (almost like a prefix) of all of the descriptions (so that it looks like Table #2). How do I insert something into the description?

I greatly appreciate anyone's help in this. It would save me counltess hours.
-T.C.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-18 : 12:45:44
[code]UPDATE svc
SET code_name=REPLACE(code_name,'CTS','RCT'),
svctype = 'AR '+ svctype[/code]
Go to Top of Page

tchelcho
Starting Member

4 Posts

Posted - 2008-06-18 : 14:37:22
THANK YOU SO MUCH!!! this will save us so much time. Have a great week.
Go to Top of Page
   

- Advertisement -