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 

krissyM
Starting Member

5 Posts

Posted - 2009-09-02 : 02:55:42
Hi,

I have a if-statement: ´

if len(@namn) > 1 begin
set @namn = replace(@namn, 'u', 'ü')
end

I would like to 'u' to be interpret as 'u' OR 'ü' how do i do this? I guess i can't use the replace statement?

@name is varchar.

Thanks,

Kris

Sachin.Nand

2937 Posts

Posted - 2009-09-02 : 03:31:44
declare @namn as varchar(10)
select @namn='ua'
if len(@namn) > 1 begin
set @namn = replace(@namn, 'u', 'ü')
end
select @namn

PBUH
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-09-02 : 04:27:42
select @namn = CASE WHEN len(@namn) > 1 THEN replace(@namn, 'u', 'ü') ELSE @namn END
Go to Top of Page

krissyM
Starting Member

5 Posts

Posted - 2009-09-02 : 05:20:16
Thank you both for quick response!! But i'm not sure if this will work - i tried it but i think maybe you misunderstood me.

We are talking about a stored procedure with input variables from a search form.

If i search for "wurzburger" the @name variable should be interpreted as "wurzburger" AND "würzburger".... i.e.... I have "würzburger" in the database which i want to be presented as a result even though you search for "wurzburger"..

I appreciate if you have any sueggestions!

Thanks,

/K

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-02 : 05:22:35

where col=@namn or col=replace(@namn,'u','ü')

Madhivanan

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

krissyM
Starting Member

5 Posts

Posted - 2009-09-02 : 06:39:01
Can you explain whats this does? Not sure if i understand this statement. What does "col" do?

Thanks,

/k
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-02 : 07:00:03
replace "col" with variable or wanted column name o your table.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

krissyM
Starting Member

5 Posts

Posted - 2009-09-02 : 08:02:20
??
Go to Top of Page
   

- Advertisement -