Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

SQL - seraching for a real number in SQL database

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.
0
tommym121
Asked:
tommym121
  • 5
  • 4
1 Solution
 
Kyle AbrahamsSenior .Net DeveloperCommented:
It's a select statement.


create procedure searchNum
@input  Real
as

select * from <table> where <col> = @input
0
 
awking00Commented:
Search in what? A column in a table, all columns in a table, all tables in a schema, all tables in a database?
0
 
tommym121Author Commented:
I am try to search in the database for such a number (real and money)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
tommym121Author Commented:
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
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
0
 
tommym121Author 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
0
 
tommym121Author Commented:
How do I put such a formula in SQL where statement?
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
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
0
 
tommym121Author Commented:
Thanks
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now