Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace Function 1

Status
Not open for further replies.

bcollinsmoose

IS-IT--Management
Aug 2, 2002
7
US
Is there a function that can be used on the SQL server that correlates to the REPLACE function in FoxPro?

I.E., I have a table with a blank field in each record (same blank field for each record). In FoxPro I can use a simple replace statement to replace the data in the field. Like:

REPLACE BlankField with "Today is a great day" for recno() > 0.

Is there any kind of function(s) that will do the same? I want to use this through ASP code.
 
if by blank you mean null, how about

update TableWithBlankField
set BlankField = "Today is a great day"
where BlankField is null codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
 
Codestorm's post was for updating the data itself... If you only need to pull the information with the data intact in the database, you can try one of these...

If blank field means NULL, try

select isnull(columnname,'Today is a great day') from table

or if blank means &quot;&quot; (empty but not null), try

select columnname = CASE
when column = &quot;&quot; then 'Today is a great day'
else column
end
from table

Play around w/ these a bit. Some variation should work for you.
 
or you could try the following:

select replace(column, ' ', 'Today is a great day') from table where recno > 0

John

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top