Solved

SQL - seraching for a real number in SQL database

Posted on 2012-03-14
10
250 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.
0
Comment
Question by:tommym121
  • 5
  • 4
10 Comments
 
LVL 39

Expert Comment

by:Kyle Abrahams
Comment Utility
It's a select statement.


create procedure searchNum
@input  Real
as

select * from <table> where <col> = @input
0
 
LVL 31

Expert Comment

by:awking00
Comment Utility
Search in what? A column in a table, all columns in a table, all tables in a schema, all tables in a database?
0
 

Author Comment

by:tommym121
Comment Utility
I am try to search in the database for such a number (real and money)
0
 
LVL 39

Expert Comment

by:Kyle Abrahams
Comment Utility
0
 

Author Comment

by:tommym121
Comment Utility
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 39

Expert Comment

by:Kyle Abrahams
Comment Utility
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
 

Author Comment

by:tommym121
Comment Utility
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
 

Author Comment

by:tommym121
Comment Utility
How do I put such a formula in SQL where statement?
0
 
LVL 39

Accepted Solution

by:
Kyle Abrahams earned 500 total points
Comment Utility
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
 

Author Closing Comment

by:tommym121
Comment Utility
Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now