Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Stored Procedure

Author  Topic 

madhulatha_b
Starting Member

22 Posts

Posted - 2006-02-28 : 00:44:08
I need to write a stored procedure to check the input parameter passed to SP is a numeric or non numeric. How to check this. please help me

I have tried in this way.. But it doesn't work

create proc isNumeric( @param varchar(60)) is
begin

declare @num decimal(20,10)
set @num= convert(decimal, @param)
if @@error = 0
return 1
else
return 0
end

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-28 : 01:03:13
Try this logic


Select data from
(
Select 'test' as data union all
select '123.45' union all
select '1002343.45' union all
select '1e3.45' union all
select '13.3345'
) T
where data not like '%[a-zA-Z]%'

Also read this
http://aspfaq.com/show.asp?id=2390

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -