Solved

Square Root in Microsoft SQL Server ?

Posted on 2001-06-29
5
1,610 Views
Last Modified: 2008-01-09
I'm trying to run the following ACCESS query on a MS SQL Server box.

SELECT (abs(Sqr((([GRIDN]-43550)^2)+(([GRIDE]-43170)^2)))/100) AS TheDistance, *
FROM Nearest

It's complaining about the Sqr function.  
Does this function exist ?

If not, how can this (Pythagora's) function be written ?

Will grade A for a quick accurate response.
0
Comment
Question by:coopa
  • 3
  • 2
5 Comments
 
LVL 18

Expert Comment

by:nigelrivett
ID: 6237574
no
sqrt(number) is t-sql

look in the bol
0
 
LVL 18

Accepted Solution

by:
nigelrivett earned 100 total points
ID: 6237579
SELECT (abs(Sqrt((power([GRIDN]-43550),2)+(power([GRIDE]-43170),2)))/100) AS TheDistance, *
FROM Nearest

could use square instead of power.
0
 
LVL 2

Author Comment

by:coopa
ID: 6237586
Testing now,

Thanks for the quick response.
If it works you win.
0
 
LVL 2

Author Comment

by:coopa
ID: 6237620

Had to swap SQRT and ABS around, also the POWER function gave errors (^2 works though) but other than that, Perfect answer.

Thanks.
0
 
LVL 2

Author Comment

by:coopa
ID: 6237669
my mistake, the ^2 does not work and POWER(value,2) does

Rich
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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

760 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

22 Experts available now in Live!

Get 1:1 Help Now