Link to home
Start Free TrialLog in
Avatar of giveindia
giveindia

asked on

Include ampersand as part of a string in a SQL query

I have the following query
Select NgoName As "NGO",  
    dbo.FormatToIndianCurrency(TotalRaised) As "Total Raised"    
      From tblNgoDailyReciepts2013 tnd with (nolock)  
      inner join manufacturer mfi with (nolock) on tnd.NgoName=mfi.Name  
where mfi.name  in (@Ngolist)  
      Order By TotalRaised desc  
I am passing a set of comma separated string  as part of the @Ngolist parameter. The query seems to work fine as long as there is no & as part of the  @Ngolist   so for example it works fine with   mfi.name  in ('A','B') . However if I have an ampersand the results are not what are expected.
So for example if I have  mfi.name  in ('A&Company','B') it does not produce the correct result.

Any ideas on how I can go about fixing this ?

Thanks,
Aditya
ASKER CERTIFIED SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of QuinnDex
QuinnDex

mfi.name  in (replace('A&Company, '&', ' ')','B')