Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with ISNUMERIC function

Status
Not open for further replies.

aruba

Programmer
Sep 5, 2003
47
Can anyone tell me why the following code won't work:

declare @p3ActID varchar(10)
declare @ACT varchar(10)
IF ISNUMERIC(RIGHT(@ACT,8))
begin
@p3ActID = RIGHT(@ACT,8)
end
end if

Thanks in advance!!
 
Whats in variable @ACT? NULL?

And SET @p3ActID = RIGHT(@ACT,8).

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.

[ba
 
@ACT is a variable which I provide, but the code doesn't work even if I use a hard-coded number such as '12345678'.
@p3ActID is the result of the function. What I'm trying to do is extract the last 8 characters of a variable, just if the input value is a number.
Thanks.
 
This code looks like VB port to SQL :)
Code:
DECLARE @p3ActID varchar(10)
DECLARE @ACT varchar(10)

SET @ACT= '12345678' -- simulated value, nothing else

IF ISNUMERIC(RIGHT(@ACT,8))[b] = 1[/b] -- returns either 1 or 0
BEGIN
	[b]SET [/b]@p3ActID = RIGHT(@ACT,8)  -- assign 8 rightmost chars to p3ActID
END

print @p3ActID -- it works
Be aware that ISNUMERIC() is not perfect - more info in: thread183-1010578.

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.

[ba
 
Thanks for the solution!!! It was what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top