• Hi

    You could always use the Geography datatype for this. I've taken your sample and added a primary key, geography column and indexed it. This should work on 2008+.

    This technet article has a description of the rules. It refers to SQL Server 2012, however this should work in 2008 +

    -- Make sure there is a primary key for the spatial index

    CREATE TABLE POSTCODESTEST(ID INT Identity(1,1) PRIMARY KEY, Latitude float, Longitude float, Postcode VARCHAR(20),Info VARCHAR(20))

    GO

    -- Inserting Data into Table

    INSERT INTO POSTCODESTEST(Latitude,Longitude,Postcode,Info)

    VALUES(51.401405,-0.196133,'SM4 5DX','Georges Crib')

    INSERT INTO POSTCODESTEST(Latitude,Longitude,Postcode,Info)

    VALUES(51.392266,-0.181435,'SM4 6DX','Tonys House')

    INSERT INTO POSTCODESTEST(Latitude,Longitude,Postcode,Info)

    VALUES(51.35898,-0.182877,'SM2 5DX','My local Pub')

    INSERT INTO POSTCODESTEST(Latitude,Longitude,Postcode,Info)

    VALUES(52.552235,-0.293517,'PE2 5DX','My Garage')

    -- add geography column and index

    ALTER TABLE POSTCODESTEST ADD Location Geography

    GO

    CREATE SPATIAL INDEX PC_SDX ON POSTCODESTEST(Location) USING GEOGRAPHY_GRID

    UPDATE POSTCODESTEST SET Location = Geography::Point(Latitude, longitude, 4326) -- check the SRID

    -- declare search point

    DECLARE @Search Geography = Geography::Point(51.392400,-0.181435,4326)

    -- get nearest neighbour

    SELECT TOP 1 Postcode, Location.STDistance(@Search) DistanceMetres, Location.STDistance(@Search) / 0.3048 DistanceFeet

    FROM POSTCODESTEST

    WHERE Location.STDistance(@Search) is not null

    ORDER BY Location.STDistance(@Search)

    Edit: fixed foot conversion