convert VBA code to SQL in SQL server
Budget: $10 – $30 USD
I have a function, which I run in MS Access and I would like to convert it to SQL Server script. It is simply to convert Yards to miles and write another one to convert miles to yards.
See below:
---Convert the vba script below to SQL Server sQL script
Public Function YDSMILES(lYardage As Long) As Double
----------------------------------------------
Dim lMileage As Long
Dim lYards As Double
Dim dResult As Double
Dim iSign As Integer
iSign = Sgn(lYardage)
lYardage = Abs(lYardage)
If lYardage >= 1760 Then
lMileage = Int(lYardage / 1760)
Else
lMileage = 0
End If
lYards = (lYardage Mod 1760) / 10000
If lMileage = 0 Then
dResult = lYards
Else
dResult = lMileage + lYards
End If
If iSign = -1 Then
dResult = 0 - dResult
End If
fYardageToMileage = dResult
End Function
See below:
---Convert the vba script below to SQL Server sQL script
Public Function YDSMILES(lYardage As Long) As Double
----------------------------------------------
Dim lMileage As Long
Dim lYards As Double
Dim dResult As Double
Dim iSign As Integer
iSign = Sgn(lYardage)
lYardage = Abs(lYardage)
If lYardage >= 1760 Then
lMileage = Int(lYardage / 1760)
Else
lMileage = 0
End If
lYards = (lYardage Mod 1760) / 10000
If lMileage = 0 Then
dResult = lYards
Else
dResult = lMileage + lYards
End If
If iSign = -1 Then
dResult = 0 - dResult
End If
fYardageToMileage = dResult
End Function