question

Matt Whitfield avatar image
Matt Whitfield asked

How do I call a static member of a CLR type?

Site seeder question: I have defined a CLR data type, used for storage of localised currency. I have a static member on that class which takes as it's input a string representing the currency symbol or name, and a decimal representing the value. How do I call it from within T-SQL code?

Edit -> Woot - going for my tumbleweed badge with this one! I'll provide an answer after a couple of days if there aren't any.

t-sqlclr
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Matt Whitfield avatar image
Matt Whitfield answered

Ok, well it's been a while :)

The answer is that you use [typename]::MethodName

Here is an example of calling the static method 'STGeomFromText' on the geography data type built in to SQL Server 2008.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.