We help IT Professionals succeed at work.

SQL - seraching for a real number in SQL database

Medium Priority
274 Views
Last Modified: 2012-08-13
I am looking for a store procedure that will help to search a real number for example 91.91

Any one know how to do it or any exisiting store procedure?

Thanks.
Comment
Watch Question

Kyle AbrahamsSenior .Net Developer
CERTIFIED EXPERT

Commented:
It's a select statement.


create procedure searchNum
@input  Real
as

select * from <table> where <col> = @input
awking00Information Technology Specialist
CERTIFIED EXPERT

Commented:
Search in what? A column in a table, all columns in a table, all tables in a schema, all tables in a database?

Author

Commented:
I am try to search in the database for such a number (real and money)
Kyle AbrahamsSenior .Net Developer
CERTIFIED EXPERT

Commented:
Kyle AbrahamsSenior .Net Developer
CERTIFIED EXPERT

Commented:
Shows the framework of how to loop through the entire database.  

Just change the last exec statement to not bring back the Left part of the column.

and change the where to @ColumnName = @SearchStr2

Author

Commented:
ged325,

Real number is approximate not precise,  I need to set a tolerance like  abs(@ColumnName - @SearchStr2)/@SearchStr2 < Tolerance to see if @ColumnName = @SearchStr2.  Tolerance can be 10E-6

Author

Commented:
How do I put such a formula in SQL where statement?
Senior .Net Developer
CERTIFIED EXPERT
Commented:
In that case do a between:

declare @min
declare @max


set @min = subtract tolerance from value

set @max = add tolerance to value

where @columnName between @min and @max

Author

Commented:
Thanks

Explore More ContentExplore courses, solutions, and other research materials related to this topic.