User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 375,195 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,137 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 1374 | Replies: 2 | Solved
Reply
Join Date: Apr 2008
Posts: 2
Reputation: Wakhal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Wakhal Wakhal is offline Offline
Newbie Poster

MS SQL Update Query

  #1  
Apr 23rd, 2008
Suppose a table ABC have column XYZ containing data

3PSY0001-06-08-F
3PSY0001A-07-09-P
3PSY0001-02-09-P
3PSY0001-07-07-F
3PSY0002-09-08-P
3PSY0002A-01-03-P
3PSY0002-07-07-F

How can i write a query so that the data ending with P without A can be updated with A.

For example, with that query, data

3PSY0001-02-09-P AND 3PSY0002-09-08-P will be updated as

3PSY0001A-02-09-P AND 3PSY0002A-09-08-P while the other data remains the same.

Please Help.

Warm Regards
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Posts: 14
Reputation: huangzhi is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 4
huangzhi huangzhi is offline Offline
Newbie Poster

Re: MS SQL Update Query

  #2  
Apr 23rd, 2008
update ABC
  set XYZ = left(XYZ, 8) + 'A' + substring(XYZ, 9, 1000)
  where XYZ like '%P' and XYZ not like '%A%'
Last edited by huangzhi : Apr 23rd, 2008 at 9:33 am.
Hence Wijaya
www.ex-Soft.tk
Reply With Quote  
Join Date: Apr 2008
Posts: 2
Reputation: Wakhal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Wakhal Wakhal is offline Offline
Newbie Poster

Re: MS SQL Update Query

  #3  
Apr 23rd, 2008
Hi Huangzhi,

Works like a charm. You are a life saver. Thanks a lot.

Warm Regards
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS SQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 2:19 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC