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 2005 Forums
 Transact-SQL (2005)
 replace

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-04-09 : 04:33:59
Hi,
The sql below replaces the 'AND' with 'OR'

declare @sql varchar(100)
set @sql = 'not "Ireland" AND "london" or "tokyo"'

print replace(@sql, 'AND', 'OR')

This is what I get. Notice that I do NOT want the word Ireland to change as it has and in it

not "irelOR" OR "london" or "tokyo"
The result should be:
not "ireland" OR "london" or "tokyo"

How can I solve this please?
Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-09 : 05:05:16


declare @sql varchar(100)
set @sql = 'not "Ireland" AND "london" or "tokyo"'

print replace(@sql, ' AND ', ' OR ')


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-04-09 : 05:27:27
Many thanks
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-09 : 06:07:02
quote:
Originally posted by arkiboys

Many thanks


You are welcome

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -