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 a varchar

Author  Topic 

tjf
Starting Member

2 Posts

Posted - 2012-10-09 : 17:05:05
I have the following issue that I am looking to solve via SQL.

A varchar contains the following:
Option 1 []
Option 2 []
Option 3 [x]
<variable text>

I would like to be able to change the lines with "Option" in them without knowing fully what the line contains. In this case I would not know that Option 1 & 2 where unchecked and Option 3 was. This means using a simple replace would not work. In pseudo code:

update Table
set VarChar
replace 'Option 1 *' with 'Option 1 [x]
replace 'Option 2 *' with 'Option 2 []
replace 'Option 3 *' with 'Option 3 []
keep rest of text unchanged

Any pointers appreciated. Thanks.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-09 : 21:21:25
sorry didnt get that. Are Option 1,Option 2 etc fields or value within a field?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tjf
Starting Member

2 Posts

Posted - 2012-10-16 : 12:13:06
They are values within a field.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-16 : 23:23:11
ok..do you've consistent format in which values are coming?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -