Re: Searching a string with spaces and nospaces in a table.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Sagar (mmsagar_at_hotmail.com)
Date: 11/30/04


Date: Mon, 29 Nov 2004 18:54:23 -0800

Aaraon -- Yes I want to return all the 4 rows.

Adam -- I guess I have not made it clear.your solution actually wont help
me.The value will be passed to the SQL.

so I want my SQL to be something like this;

SELECT * from
#org
WHERE OrgName LIKE @OrgName

WHERE @orgName I will pass and I will pass @orgName as 'GC Systems' or 'G C
Systems'.

I am looking for a solution based on the parameter.

Thanks

Meher

"Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message
news:eLOlEUo1EHA.3820@TK2MSFTNGP11.phx.gbl...
> ??
>
> SELECT *
> FROM #org
> WHERE OrgName LIKE 'G%C%Systems'
>
>
> I'm not sure what you're hoping for, but that will do it...
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
>
> "Meher Malakapalli" <mmalakapalli@cohesioninc.com> wrote in message
> news:uAEPW4n1EHA.2712@TK2MSFTNGP09.phx.gbl...
>> Hi,
>>
>> How do I return string with spaces and no spaces using the same search
>> criteria. For example I have the following table.
>>
>> Create table #org (RowID INT Identity(1,1),
>> OrgName VARCHAR(40)
>> )
>>
>> INSERT INTO #org Values('GC Systems')
>> INSERT INTO #org Values('GC Systems')
>> INSERT INTO #org Values('G C Systems')
>> INSERT INTO #org Values('G C R Systems')
>>
>> Select * from #org
>>
>>
>> I want to return all the 4 rows when the search criteria is LIKE GC
> Systems
>> or LIKE G C Systems. I dont want to hardcode the string name. I want to
> pass
>> the string as a variable to my select statement.
>>
>> Any help is appreiciated.
>>
>> Thanks
>>
>> DDL:
>>
>> Create table #org (RowID INT Identity(1,1),
>> OrgName VARCHAR(40)
>> )
>>
>> INSERT INTO #org Values('GC Systems')
>> INSERT INTO #org Values('GC Systems')
>> INSERT INTO #org Values('G C Systems')
>> INSERT INTO #org Values('G C R Systems')
>>
>> Select * from #org
>>
>> Drop table #org
>>
>> M
>>
>>
>
>



Relevant Pages

  • Re: Searching a string with spaces and nospaces in a table.
    ... set @var = 'GC Systems' ... > INSERT INTO #org Values ... > I want to return all the 4 rows when the search criteria is LIKE GC ... I dont want to hardcode the string name. ...
    (microsoft.public.sqlserver.programming)
  • Re: SIP Quiz
    ... sixth claw, patent gate, tenth life, stretched fore, string ... structure, main concourse ... Change "nospam" to my first name and .org to .com to reply ...
    (rec.arts.sf.written)
  • Re: Searching a string with spaces and nospaces in a table.
    ... "Meher Malakapalli" wrote in message ... > INSERT INTO #org Values ... > I want to return all the 4 rows when the search criteria is LIKE GC ... I dont want to hardcode the string name. ...
    (microsoft.public.sqlserver.programming)
  • Why align ?
    ... The following is MASM generated assembly code for the helloworld ... I don't know why a 'ORG $+2' after the Hello string. ... it for the alignment purpose? ...
    (comp.lang.asm.x86)