Re: Nasty Test string SELECT Statement

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: David Hills (dhills_at_pcfe.ac.uk)
Date: 04/30/04


Date: Fri, 30 Apr 2004 07:53:26 -0700


Thanks for your replys

this code below works, but I also need to return in the query the first
number from the number table that exists

nn.number nasty_string
11002 "#(9322 9742 10582 11002 11422 )"

Sorry thats not explained clearly!!
What I need is to return the nn.number that gives the first postive
EXISTS result in the WHERE CLAUSE

create TABLE #numbers
(number INTEGER)

delete #numbers
declare @mycount as integer
set @mycount=14280
WHILE @mycount < 14339
BEGIN
insert into #numbers
values (@mycount)
set @mycount=@mycount+1
END
--select * from #Numbers

SELECT nasty_string
                         FROM sdvp_activ_schedul
                   WHERE EXISTS(
                select * from #numbers nn
                where number between 14280 and 14339
                AND CHARINDEX(' '+CAST(nn.number as varchar)+' ',nasty_string)>0
                        )

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Relevant Pages

  • Re: obtain TOP n values per day (multiple days)
    ... SELECT Field2, Date1, myCount ... WHERE myCount IN(SELECT TOP 30 myCount ... ORDER BY Date1 ASC, myCount DESC ... The outermost query keep the record if it is in the top 30 returned by the ...
    (microsoft.public.access.queries)
  • Re: Query Variables
    ... to accomplish a query the most efficient way possible. ... WITH MyCount AS ( ... This could be different in a future version of SQL Server. ... If you want to store an intermediate result, you need to use a table ...
    (comp.databases.ms-sqlserver)