-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: Pandurang_Nayak
Message 7 in Discussion
A non-helper piece of code
here:
I got the logic a bit wrong. this one checks
for any of the numbers being available in any of the records, and fails if it
exists.
DECLARE @str varchar(20)
DECLARE @originalstr varchar(20)
DECLARE
@innerstr varchar(10)
DECLARE @tempflag bit
DECLARE @tblcount int
set
@str='44,66,77,55'
set @[EMAIL PROTECTED]
set @innerstr=''
set
@tempflag=0
WHILE @str <> ''
BEGIN
if charindex(',', @str)
> 0
begin
set @innerstr = substring(@str, 0,
charindex(',',
@str))
end
else
begin
set @innerstr =
@str
end
print @innerstr
if charindex(',', @str)
> 0
begin
set @str = substring(@str, charindex(',',
@str) + 1, len(@str)-charindex(',',
@str))
end
else
begin
set @str =
''
end
-- Do the actual checking for the value in
the column
SELECT @tblcount = COUNT(*) from X where field2 like '%' +
@innerstr + '%'
if @tblcount > 0
begin
--
This means record exists
GOTO
INSERTFAIL
end
END
set @tempflag = 0
-- success
INSERT INTO X VALUES ('fieldval', @originalstr)
-- failure handler
INSERTFAIL:
if @tempflag = 1
begin
print 'failure because the value ' + @innerstr + ' already
exists'
end
however, i gather this is not your
requirement. am trying to refine this further. in the meantime, maybe this will
give you some direction.
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]