Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

SQL query in 2012 works, 2005 does not

$
0
0
I have the following query that i need help with converting it to syntax that MS SQL 2005 would understand since FORMAT among other things in it are not supported by that old version.
Code:

"SELECT " & _
    "TMP.*," & _
    "COUNT(*) OVER () AS rCount " & _
"FROM (" & _
    "SELECT venueID, " & _
        "venueName AS venueName, " & _
        "venueAddress + ', ' + venueCity + ', ' + venueState + ' ' + venueZip AS venueAddress, " & _
        "venueLatLong AS coordinates, " & _
        "FORMAT(venueEventDate, 'MM/dd/yyyy', 'en-US') + ' @ ' + CONVERT(VARCHAR,venueTime) AS dateAndTime, " & _
        "SUBSTRING(venueLatLong, 1, CHARINDEX(',', venueLatLong)-1) AS Lat, " & _
        "SUBSTRING(venueLatLong, CHARINDEX(',', venueLatLong) + 1, 1000) AS Lng, " & _
        "(round(" & _
            "3959 * acos " & _
              "(" & _
                  "cos(radians('" & center_lat & "')) " & _
                  "* cos(radians(SUBSTRING(venueLatLong, 1, CHARINDEX(',', venueLatLong)-1))) " & _
                  "* cos(radians(SUBSTRING(venueLatLong, CHARINDEX(',', venueLatLong) + 1, 1000)) " & _
                  "- radians('" & center_lng & "')) " & _
                  "+ sin(radians('" & center_lat & "')) " & _
                  "* sin(radians(SUBSTRING(venueLatLong, 1, CHARINDEX(',', venueLatLong)-1)))" & _
              ")" & _
        ", 1, 1)) AS distance " & _
        "FROM meetUpMarkers) " & _
    "TMP " & _
"WHERE distance < " & radius & " " & _
"ORDER BY venueName,distance DESC;"

I tried to replace FORMAT with CONVERT but it still seems to be incorrect.

When i change FORMAT to CONVERT i get the error:

Type venueEventDate is not a defined system type.

Would appreciate the help.

Viewing all articles
Browse latest Browse all 13329

Trending Articles