Solved

Square Root in Microsoft SQL Server ?

Posted on 2001-06-29
5
1,637 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
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.

635 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