Reputation: 1491
Using SQL Server Management Studio:
declare @g geography
set @g = geography::Point(-77.1851436,39.1065236,4326)
select @g
returns
0xE6100000010C14C48A64D94B53C04820B990A28D4340
What format is this result? I know that it is not STAsBinary() - that returns
0x01010000004820B990A28D434014C48A64D94B53C0
Is there a way to create the 0xE61... value using C#?
Upvotes: 3
Views: 353
Reputation: 1241
result is type of Microsoft.SqlServer.Types.SqlGeography.Point
see this link
Upvotes: 2
Reputation: 101453
This is special binary format defined here (you may download PDF there if interested about details of that format). You can create such value in C# like this (reference Microsoft.SqlServer.Types
assembly):
var pt = SqlGeography.Point(-77.1851436, 39.1065236, 4326);
var binary = pt.Serialize().Value;
var hexString = "0x" + BitConverter.ToString(binary).Replace("-", "");
Upvotes: 4