How to use spatial data types in SQL Server Database project

Ali Shah
Ali Shah used Ask the Experts™
Hi guys,

I want to write the stored procedures and the UDF etc in managed code using C#CLR, however i am struggling to find the namespace to be used in SQL Database project type.

This name space has got the spatial data types but this is not available in the SQL Server Database project.

For instance i am writing a UDF in CLR managed code and i want to use the geography data type.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010
Are you able to install the Microsoft.SqlServer.Types from NuGet ?  I had to do this in order to use SQL spatial types in my C# project.

using Microsoft.SqlServer.Types;

Open in new window

If you're still not able to include it after installing the NuGet package, try adding the dll as a reference in your project (you may need to use the Browse option in the Reference Manager)
Ali ShahSQL Developer


Thanks with your suggestion i was able to download the dll file and then added it as a reference and it worked. i suppose perhaps in SQL Server i would need to register that dll.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial