Re: Searching a string with spaces and nospaces in a table.
From: Sagar (mmsagar_at_hotmail.com)
Date: 11/30/04
- Next message: Aaron [SQL Server MVP]: "Re: Searching a string with spaces and nospaces in a table."
- Previous message: Adam Machanic: "Re: cannot copy image column from table to table"
- In reply to: Adam Machanic: "Re: Searching a string with spaces and nospaces in a table."
- Next in thread: Aaron [SQL Server MVP]: "Re: Searching a string with spaces and nospaces in a table."
- Reply: Aaron [SQL Server MVP]: "Re: Searching a string with spaces and nospaces in a table."
- Messages sorted by: [ date ] [ thread ]
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
>>
>>
>
>
- Next message: Aaron [SQL Server MVP]: "Re: Searching a string with spaces and nospaces in a table."
- Previous message: Adam Machanic: "Re: cannot copy image column from table to table"
- In reply to: Adam Machanic: "Re: Searching a string with spaces and nospaces in a table."
- Next in thread: Aaron [SQL Server MVP]: "Re: Searching a string with spaces and nospaces in a table."
- Reply: Aaron [SQL Server MVP]: "Re: Searching a string with spaces and nospaces in a table."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|