[thelist] Stored procedure
Stevenson Ngila
Stevenson at epr.footman-walker.com
Mon Feb 10 01:22:01 CST 2003
Thank you very much darren. This works perfectly.
-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of darren
Sent: 07 February 2003 17:36
To: thelist at lists.evolt.org
Subject: Re: [thelist] Stored procedure
On Friday, February 7, 2003 at 13:22, Stevenson Ngila wrote:
SN> if i have a string "56,57,58,59" and i have "56", how can i loop
SN> through the first string and check if the 56 exists in the string using
an
SN> sql stored procedure?
if this is ms sql server...
declare @aString varchar(100)
declare @toFind varchar(50)
set @aString = '56,57,58,59'
set @toFind = '56'
-- make sure we have a , at the start and end of the strings
-- means we don't match 56 in 5676,1234...
set @aString = ',' + @aString + ','
set @toFind = ',' + @toFind + ','
if PatIndex('%' + @toFind + '%', @aString) > 0
BEGIN
-- we have the string
END
ELSE
BEGIN
-- we don't have the string
END
hth,
darren.
--
* * Please support the community that supports you. * *
http://evolt.org/help_support_evolt/
For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !
More information about the thelist
mailing list