Friday, September 7, 2012

Drawing a circle in SQL Server...

I've just started playing with the Geo spatial data types in SQL Server Express.
The first thing I wanted to do was draw a circle.  How difficult could it be?

I could not find an example on the interweb - so I put one together.

-- Draw Circle

declare @RecCount float = 360
declare @count int = 0
declare @size int = 1
declare @tmpTable table ( geo geometry)
while(@count < @RecCount)
begin
insert into @tmpTable
SELECT geometry::STGeomFromText('POINT('
   +  cast(SIN(RADIANS((CAST(@count AS FLOAT)
            /CAST(@RecCount AS FLOAT))
            * 360)) * @size as varchar)
   + ' '
   + cast(COS(RADIANS((CAST(@count AS FLOAT)
            /CAST(@RecCount AS FLOAT))
            * 360)) * @size as varchar)
   + ')',4326) AS Posn
set @count = @count + 1
end


select geo from @tmpTable






Now choose the 'Spatial Results' tab - you might have never seen this before. It only appears if the results set has a geospatial data type in it.


Draw a Circle

The observant of you might notice, it's not actually a circle.

Happy Coding...!!!






Change Cursor to hand on mouseover using JQuery...



When ever we need to change the mouse cursor using JQuery then we can do it very easily.


In my today's post I will show you how can we change the mouse cursor to the Hand type cursor while user hover mouse on the particular element.
It is very simple just look at the below JQuery code.
 



My Code:


$(document).ready(function()
  {
    $("#elementid").hover(function()
     {
       $(this).css("cursor", "hand");
     });
});


In above code "elementid" is the name of the element on which you want a mouse pointer as a hand while hovering a mouse over it.

Happy Coding...!!!