Solved

SQL - seraching for a real number in SQL database

Posted on 2012-03-14
10
253 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 40

Expert Comment

by:Kyle Abrahams
ID: 37720126
It's a select statement.


create procedure searchNum
@input  Real
as

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

Expert Comment

by:awking00
ID: 37720471
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
ID: 37721176
I am try to search in the database for such a number (real and money)
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 37721216
0
 

Author Comment

by:tommym121
ID: 37722761
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 37724930
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
ID: 37742225
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
ID: 37742231
How do I put such a formula in SQL where statement?
0
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 37743215
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
ID: 37745731
Thanks
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

827 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