{"id":2637,"date":"2008-06-06T04:07:00","date_gmt":"2008-06-06T04:07:00","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/clr-beer-and-turkey\/"},"modified":"2017-08-10T12:54:31","modified_gmt":"2017-08-10T12:54:31","slug":"clr-beer-and-turkey","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/clr-beer-and-turkey\/","title":{"rendered":"CLR, beer and turkey"},"content":{"rendered":"<p class=\"MsoNormal\">It is strange that two important programming techniques in a SQL Server Database can&#8217;t be done in TSQL. The first is, of course, being able to read multiple results from a stored procedure. You can do it in ODBC\/ADO and so on, but not in TSQL. The other obvious failing is that one cannot write user aggregate functions (which perform a calculation on a set of values and returns a single value) in the same way as scalar or table functions, except by using the CLR integration. TSQL can&#8217;t help you to add your own functions to SUM(), COUNT(), MAX() MIN() etc. <\/p>\n<p class=\"MsoNormal\">CLR integration was, along with Notification Services, the surprising turkey of the SQL Server 2005 launch. In reality, it was often doubling the development time over T-SQL procedures\/functions. Whereas the task of building a function in T-SQL is trivial (load up management studio, edit the template, save and test), the construction of a CLR function was only made easy in the expensive VS Pro. Even so, there were two extra steps and a lot more for us who had only VS Standard. &#160;Microsoft had failed to build the CLR development process into Management Studio. CLR integration was over-sold as an alternative to TSQL rather than a replacement for Extended Stored procedures.<\/p>\n<p class=\"MsoNormal\">Where you have to construct a custom aggregate function, then CLR is the only way there is, so should that be enough to send us scurrying to our cheque-books to buy VS Pro? &#160;We had an editorial discussion about doing a workbench on CLR Aggregate functions. Phil loved the idea, but insisted on a really useful example, that readers would actually want. &#160;Even a couple of Adnams Broadsides failed to bring from any of us an example besides concatenation, and that is already in Books-on-Line, and can be done without CLR. The idea is still there on the back-burner.<\/p>\n<p class=\"MsoNormal\">So, what are you using CLR for? Are you writing user aggregation functions, or using it to access powerful CLR libraries such as Regex? Even if you&#8217;ve looked at it and abandoned the idea of using it, we&#8217;d be interested to hear why. Usual rules apply &#8211; a prize to the best contribution.<\/p>\n<p class=\"MsoNormal\">Cheers,<\/p>\n<p class=\"MsoNormal\">Tony.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is strange that two important programming techniques in a SQL Server Database can&#8217;t be done in TSQL. The first is, of course, being able to read multiple results from a stored procedure. You can do it in ODBC\/ADO and so on, but not in TSQL. The other obvious failing is that one cannot write&#8230;&hellip;<\/p>\n","protected":false},"author":200703,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2,47125],"tags":[],"coauthors":[],"class_list":["post-2637","post","type-post","status-publish","format-standard","hentry","category-blogs","category-editorials"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2637","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/200703"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=2637"}],"version-history":[{"count":3,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2637\/revisions"}],"predecessor-version":[{"id":72066,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2637\/revisions\/72066"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=2637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=2637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=2637"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=2637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}