SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 updating a varchar
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tjf
Starting Member

2 Posts

Posted - 10/09/2012 :  17:05:05  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 10/09/2012 :  21:21:25  Show Profile  Reply with Quote
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 - 10/16/2012 :  12:13:06  Show Profile  Reply with Quote
They are values within a field.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/16/2012 :  23:23:11  Show Profile  Reply with Quote
ok..do you've consistent format in which values are coming?

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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000