Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Formatting string in WHERE clause

Reply
Thread Tools

Re: Formatting string in WHERE clause

 
 
Lee Simpson
Guest
Posts: n/a
 
      07-18-2003
Here is a potential solution:

declare @Criteria varchar(700)
declare @Comma int

set @Criteria = 'White,Green'

create table #tmp (Name varchar(100))

while (CharIndex(',', @Criteria)>0)
begin
set @Comma = CharIndex(',', @Criteria)

insert into #tmp select substring(@Criteria, 0, @Comma)
select @Criteria = substring(@Criteria, @Comma+1, datalength(@Criteria))
end --while

insert into #tmp select @Criteria

select *
from authors a,
#tmp b
where a.au_lname = b.Name



Hope this helps, always glad to help out a fellow South African...

Regards
Lee Simpson
UK




"Corrie Taljaard" <(E-Mail Removed)> wrote in message
news:bf8h49$cc0$(E-Mail Removed)...
> Hi ,
> I'm having a problem formatting a string to be used in the WHERE clause.
> Here is my code
>
> DECLARE @Criteria varchar(700)
>
> 'The formatting that i tried without success
> Using 2 ( ' ) hypens next to each other
> SET @Criteria = ' ' + ''LSACONXB'' + ',' + ''ALTLCNXB'' + ',' +
> ''CAGECDXH''+ ',' + ''REFNUMHA'' + ' '
>
> Using ( " ) double quotes
>
> SET @Criteria = ' ' + "LSACONXB" + ',' + "ALTLCNXB" + ',' + "CAGECDXH"

+
> ',' + "REFNUMHA" + ' '
>
> Using a combination of ( " ) double quotes and ( ' ) hypen
> SET @Criteria = ' ' + '"LSACONXB"' + ',' + '"ALTLCNXB"' + ',' +
> '"CAGECDXH"' + ',' + '"REFNUMHA"' + ' '
>
> The testing code with IN
> WHERE (Static.dbo.intWindow.GuiID = @GUIWindowID)
>
> This is the code part used with a variable
> --AND (Static.dbo.intField.FieldName IN (@Criteria))
>
> That has to coincide with the following codepart
> --AND (Static.dbo.intField.FieldName IN

('LSACONXB','ALTLCNXB','CAGECDXH'))
>
>
> Any help appriciated
> Thanks in advance
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
String concatenation vs. string formatting Andrew Berg Python 13 07-10-2011 11:24 PM
String formatting with the format string syntax Andre Alexander Bell Python 9 09-15-2010 10:35 AM
Quartus II error - use clause error... - very strange behaviour Jan VHDL 2 12-16-2004 03:33 PM
Need formatting options menu for formatting hard drive Mark T. Computer Support 3 11-24-2003 11:50 PM



Advertisments