PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.sqlserver.server > search for apostrophes like ' % ' % '
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
search for apostrophes like ' % ' % '

Réponse
 
LinkBack Outils de la discussion
Vieux 03/09/2008, 16h36   #1
Scott
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut search for apostrophes like ' % ' % '

Hi,

Have a programmer thats allowed users to enter "apostrophe" is a name field.
Im attempting to search of them using:

select * from table where [name] like '% ' %'

i.e

' % ' % ' (with no spaces)

and am hitting the obvious problem that the second "apostrophe" is seen as
the end of the string. Can anyone with a solution ?

Thanks for your time
Scott


  Réponse avec citation
Vieux 03/09/2008, 16h44   #2
Plamen Ratchev
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: search for apostrophes like ' % ' % '

You have to use two apostrophes in the search pattern, like '%''%'.

SELECT x
FROM (SELECT 'O''Conner'
UNION
SELECT 'Conner') AS T(x)
WHERE x LIKE '%''%';

--
Plamen Ratchev
http://www.SQLStudio.com
  Réponse avec citation
Vieux 03/09/2008, 16h47   #3
Uri Dimant
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: search for apostrophes like ' % ' % '

Scott
create table #t (c varchar(50))

insert into #t values ('John')

insert into #t values ('O''Brian')



select * from #t

where c like '%''%'





"Scott" <scott_lotus@yahoo.co.uk> wrote in message
news:OylGtJdDJHA.4800@TK2MSFTNGP06.phx.gbl...
> Hi,
>
> Have a programmer thats allowed users to enter "apostrophe" is a name
> field. Im attempting to search of them using:
>
> select * from table where [name] like '% ' %'
>
> i.e
>
> ' % ' % ' (with no spaces)
>
> and am hitting the obvious problem that the second "apostrophe" is seen as
> the end of the string. Can anyone with a solution ?
>
> Thanks for your time
> Scott
>



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 08h04.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07793 seconds with 11 queries