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
 SQL Server 2012 Forums
 Transact-SQL (2012)
 finding two different value in a column & update

Author  Topic 

ppatel112
Starting Member

35 Posts

Posted - 2014-11-13 : 17:55:38
Hi folks,

i have two different statements as below where it looks for string 'rabobank' and 'rabo'. finally it updates with 'WNZ'

UPDATE JobConfiguration SET ConfigurationValue = REPLACE( CAST(ConfigurationValue as varchar(max) ), 'Rabobank', 'WNZ')

UPDATE JobConfiguration SET ConfigurationValue = REPLACE( CAST(ConfigurationValue as varchar(max) ), 'rabo', 'wnz')

how we can combine this two in one?

thanks

sunder.bugatha
Yak Posting Veteran

66 Posts

Posted - 2014-11-14 : 04:17:23
Are you trying to replace 'rabo' or 'rabobank' ? if u run the second statement first then the first statement will be invalid as the string 'rabobank' itself will be 'wnzbank'.

can you please clarify on your requirement?

Hema Sunder
Go to Top of Page

achettipalli
Starting Member

1 Post

Posted - 2014-11-17 : 09:45:07
Hello patel,

you can apply basic update function to get the results:

UPDATE JobConfiguration SET ConfigurationValue = 'WNZ' where ConfigurationValue = 'Rabobank' or ConfigurationValue = 'Rabo'

you can still use CAST to the above one.
let me know if this is your requirement..



~AC~
Go to Top of Page
   

- Advertisement -