SQL Server 2008 - Worth the Wait
Source : Books On line, SQL Server 2008
The example above will create a shape which has joined points (1, 1), (4, 5), (10, 13) and (19, 25). Even though I have specified only X and Y coordinates, you have the option of providing Z and M parameters as well.
There are several valuable methods which you can use with the LineString shape.
Method
Usage
Syntax
Result for Above Sample
STLength()
Total length
Select @g.STLength()
30
STStartPoint()
Start point of the LineString
Select @g.STStartPoint().ToString();
POINT (1, 1)
STEndPoint()
End point of the LineString
Select @g.STEndPoint().ToString();
POINT( 19, 25)
STPointN()
Point of the given number of the LineString object.
Select @g.STPointN(2).ToString();
POINT (4, 5)
STNumPoints()
Number of points
Select @g.STNumPoints();
4
STIsSimple()
If shape does not intersect itself then it is 1
Select @g.STIsSimple();
1
STIsClosed()
If shape is closed then it is 1
Select @g.STIsClosed();
0
STIsRing()
If it simple and closed
Select @g.STIsRing();
Select @g.STLength() Select @g.STStartPoint().ToString(); Select @g.STEndPoint().ToString(); Select @g.STPointN(2).ToString(); Select @g.STNumPoints(); Select @g.STIsSimple(); Select @g.STIsClosed() Select @g.STIsRing(); In my testing I have found that there are some errors when the LineString shape is closed. These issues should be fixed in a coming release.
Next Page>>