{"id":12012,"date":"2019-05-05T21:45:30","date_gmt":"2019-05-05T21:45:30","guid":{"rendered":"https:\/\/dbtut.com\/?p=12012"},"modified":"2019-05-05T21:46:32","modified_gmt":"2019-05-05T21:46:32","slug":"what-is-clr-and-how-to-import-dll-in-sql-server","status":"publish","type":"post","link":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/","title":{"rendered":"What is CLR and How to import dll in sql server"},"content":{"rendered":"<p>CLR is a feature introduced with SQL Server 2005.<\/p>\n<p>Using the CLR (Common Language Runtime), you can perform a number of complex processes that you cannot do with TSQL using the .NET Framework, and you can import the dll into SQL Server and use it at the database level.<\/p>\n<p>You can also write stored procedures, triggers, user-defined types, user-defined functions (scalar and table-valued) and user-defined aggregate functions in any net.framework language.<\/p>\n<p><strong>NOTE:<\/strong> You cannot perform these operations on Visual Studio 2003.<\/p>\n<p>Let&#8217;s clarify the CLR by making an example. First, the CLR must be activated at the instance level.<\/p>\n<pre class=\"lang:default decode:true \">sp_configure 'show advanced options', 1;\nGO\nRECONFIGURE;\nGO\nsp_configure 'clr enabled', 1;\nGO\nRECONFIGURE;\nGO<\/pre>\n<p>Then let&#8217;s prepare a code with Visual Studio. I have written a program that contains the following code that calculate the free space on the disks. You can use this code. In this article, we will import the dll generated by this code into the sql server and then use this dll to run the script that calculates the free space on the disks with tsql.<\/p>\n<p>I will prepare my application using Visual Studio 2010. First, we&#8217;ll open a new SQL CLR project through Visual Studio as follows. But I will show what is difference in Visual Studio 2015 at the end of the article.<\/p>\n<p id=\"fiDpbzv\"><img loading=\"lazy\" decoding=\"async\" width=\"670\" height=\"129\" class=\"size-full wp-image-12014  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccdf325be13a.png\" alt=\"\"><\/p>\n<p>We select SQL Server from the Database tab and then select &#8220;Visual C # SQL CLR Database Project&#8221;. If you want to write your code with Visual Basic, you should select &#8220;Visual Basic SQL CLR Database Project&#8221;.<\/p>\n<p>We named our application &#8220;SqlServerCLRUygulamasi&#8221;.<\/p>\n<p id=\"SLwsGUL\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-12015  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccdf391eef48.png\" alt=\"\" width=\"744\" height=\"281\"><\/p>\n<p>When we click OK gives a warning as follows. This warning implies that if we are developing our application for SQL Server 2005 or SQL Server 2008, we need to have the .NET Framework 3.5 installed on the server on which we have developed the application, and we can change the version of the .NET Framework that the application uses from the properties tab of the project.<\/p>\n<p id=\"bazkmbU\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-12016  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccdf3f77a681.png\" alt=\"\" width=\"598\" height=\"339\"><\/p>\n<p>From Solution Explorer, you can right-click the project and then click on Properties to set the .net framework as follows.<\/p>\n<p id=\"efELtDp\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-12017  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccdf4560cbf6.png\" alt=\"\" width=\"740\" height=\"325\"><\/p>\n<p>After clicking OK, we will choose the SQL Server Instance. Click Add New Reference.<\/p>\n<p id=\"AgBgAAr\"><img loading=\"lazy\" decoding=\"async\" width=\"515\" height=\"598\" class=\"size-full wp-image-12018  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccdf4be1f2c2.png\" alt=\"\"><\/p>\n<p>In the screen that appears, we write the instance name in the &#8220;Server name&#8221; section where we will import dll, in the &#8220;Connect to database&#8221; section, we write the related database name.<\/p>\n<p id=\"qMsCsMg\"><img loading=\"lazy\" decoding=\"async\" width=\"594\" height=\"754\" class=\"size-full wp-image-12019  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccdf51cb9657.png\" alt=\"\"><\/p>\n<p>When we click Ok, it gives a warning as follows. This warning says that SQL \/ CLR should be activated.<\/p>\n<p>And it asks if we want to activate SQL \/ CLR. Click Yes to continue.<\/p>\n<p id=\"smdWezh\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-12020  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccdf59a7693d.png\" alt=\"\" width=\"608\" height=\"322\"><\/p>\n<p>You can also enable CLR at instance level with the help of the following script.<\/p>\n<pre class=\"lang:default decode:true \">sp_configure 'show advanced options',1\nreconfigure\nGO\nsp_configure 'clr enabled',0\nreconfigure<\/pre>\n<p>After opening the project, you can add the Item you want by clicking Add as below.<\/p>\n<p id=\"JdPJSgN\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-12021  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccdf5fc9da51.png\" alt=\"\" width=\"690\" height=\"310\"><\/p>\n<p>We select Class from the above screen and add the following libraries on the page.<\/p>\n<pre class=\"lang:default decode:true \">using System.IO;\nusing Microsoft.SqlServer.Server;\nusing System.Data.SqlTypes;\n<\/pre>\n<p id=\"iluNVKt\"><img loading=\"lazy\" decoding=\"async\" width=\"564\" height=\"381\" class=\"size-full wp-image-12023  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccdf665bd369.png\" alt=\"\"><\/p>\n<p>In order to avoid getting errors during importing dll into sql server,, dll into sql server, we define class and function as public as above. It is also important that the function is static.<\/p>\n<p>I&#8217;m sharing the code below so you can copy it.<\/p>\n<pre class=\"lang:default decode:true\">[SqlProcedure]\n        public static void GetTotalFreeSpace(String name, out String message)\n        {\n            message = \"\";\n\n            foreach (DriveInfo drive in DriveInfo.GetDrives())\n            {\n                if (drive.IsReady &amp;&amp; drive.Name == name)\n                {\n                    message = Convert.ToDecimal(drive.TotalFreeSpace \/ 1024.0 \/ 1024.0 \/ 1024.0).ToString(\"#.##\");\n\t\tBreak;\n\n                }\n                else\n                { \n                message=\"Disk Not Found\";\n                }\n            }\n        }<\/pre>\n<p>Then we build our project as follows.<\/p>\n<p id=\"bMYtPNw\"><img loading=\"lazy\" decoding=\"async\" width=\"305\" height=\"139\" class=\"size-full wp-image-12024  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccdf7680f57c.png\" alt=\"\"><\/p>\n<p>After building, the dll of our project was created. Click on &#8220;SQLServerCLRUygulamasi&#8221; in the Solution Explorer on the right, go to the path in ProjectFolder on the Properties tab, copy the file from bin-&gt; Debug, and paste it to the place you want. I copied it to the &#8220;C:\\Backup&#8221; folder.<\/p>\n<p>Then we import the code to the sql server with the help of the following script.<\/p>\n<pre class=\"lang:default decode:true \">CREATE ASSEMBLY DiskFreeSpace from 'C:\\Backup\\SqlServerCLRUygulamasi.dll' WITH PERMISSION_SET = UNSAFE;<\/pre>\n<p>If TRUSTWORTHY is not active in the database, the code above will receive the error as follows.<\/p>\n<p><span style=\"color: #ff0000;\"><em>Msg 10327, Level 14, State 1, Line 9<\/em><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><em>CREATE ASSEMBLY for assembly &#8216;SqlServerCLRUygulamasi&#8217; failed because assembly &#8216;SqlServerCLRUygulamasi&#8217; is not authorized for PERMISSION_SET = UNSAFE.&nbsp; The assembly is authorized when either of the following is true: the database owner (DBO) has UNSAFE ASSEMBLY permission and the database has the TRUSTWORTHY database property on; or the assembly is signed with a certificate or an asymmetric key that has a corresponding login with UNSAFE ASSEMBLY permission.<\/em><\/span><\/p>\n<p>You can use the following script to enable TRUSTWORTHY in the database. Enabling TRUSTWORTH may cause some risks. I explained these risks in my article &#8220;<a href=\"https:\/\/dbtut.com\/index.php\/2018\/10\/31\/how-to-give-restrict-access-to-dmw-and-dmf-to-logins-without-giving-view_server_state-permission\/\" target=\"_blank\" rel=\"noopener noreferrer\">How To Give Restrict Access To dmw and dmf To Logins Without Giving View_Server_State Permission<\/a>&#8220;.<\/p>\n<pre class=\"lang:default decode:true \">ALTER DATABASE AdventureWork2014 SET TRUSTWORTHY ON\nGO\n<\/pre>\n<p>After enabling TRUSTWORTHY in the database as above, I am running ASSEMBLY create script in UNSAFE mode and then creating a stored procedure that will use this DLL as below.<\/p>\n<pre class=\"lang:default decode:true\">CREATE PROCEDURE DiskFreeSpace_SP\n@diskname nvarchar(200),\n@message nvarchar(MAX)OUTPUT\nAS EXTERNAL NAME DiskFreeSpace.[SqlServerCLRUygulamasi.Class1].GetTotalFreeSpace\nGO\n<\/pre>\n<p>When I run the Stored Procedure as follows, it shows me the free space on disk C as follows.<\/p>\n<pre class=\"lang:default decode:true \">DECLARE @message varchar(MAX)\nEXEC DiskFreeSpace_SP 'C:\\',@message output\nPRINT @message\n<\/pre>\n<p>If you set the ASSEMBLY code as SAFE, you may receive an error as follows when you run the stored procedure.<\/p>\n<p><span style=\"color: #ff0000;\"><em>Msg 6522, Level 16, State 1, Procedure DiskFreeSpace_SP, Line 22<\/em><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><em>A .NET Framework error occurred during execution of user-defined routine or aggregate &#8220;DiskFreeSpace_SP&#8221;:<\/em><\/span><\/p>\n<p>Creating a project and class on Visual Studio 2015 is slightly different. First, we create the project as a SQL Server Database Project.<\/p>\n<p id=\"dUYtWyc\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-12028  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccf564d31d4f.png\" alt=\"\" width=\"766\" height=\"225\"><\/p>\n<p>Then right click on the project and click on Add New Item as below.<\/p>\n<p id=\"aUkrHFo\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-12029  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccf56820ab04.png\" alt=\"\" width=\"750\" height=\"504\"><\/p>\n<p>We select &#8220;SQL CLR C #&#8221; under SQL Server as below, and we add Class.<\/p>\n<p id=\"yhCxuQk\"><img loading=\"lazy\" decoding=\"async\" width=\"556\" height=\"283\" class=\"size-full wp-image-12030  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccf56d4bf6a4.png\" alt=\"\"><\/p>\n<p>To do the framework setting in Visual Studio 2015, right-click the project and click Properties as follows.<\/p>\n<p id=\"YfEmIrR\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-12031  aligncenter\" src=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/img_5ccf5746abd56.png\" alt=\"\" width=\"727\" height=\"455\"><\/p>\n\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_12012\" class=\"pvc_stats all  \" data-element-id=\"12012\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>CLR is a feature introduced with SQL Server 2005. Using the CLR (Common Language Runtime), you can perform a number of complex processes that you cannot do with TSQL using the .NET Framework, and you can import the dll into SQL Server and use it at the database level. You can also write stored procedures, &hellip;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_12012\" class=\"pvc_stats all  \" data-element-id=\"12012\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":12033,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[3],"tags":[3812,3808,3819,3825,3811,3821,3824,3816,3820,3814,3817,3813,3818,3827,3815,3826,3828,3809,3810,3822,3823],"class_list":["post-12012","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-mssql","tag-a-net-framework-error-occurred-during-execution-of-user-defined-routine-or-aggregate-diskfreespace_sp","tag-create-assembly-for-assembly-failed-because-assembly-is-not-authorized-for-permission_set-unsafe","tag-debug-sql-clr-visual-studio","tag-deploy-clr-function-to-sql-server","tag-enable-trustworthy","tag-how-do-i-debug-clr-in-stored-procedure","tag-how-do-you-create-a-dll-file","tag-how-to-call-c-method-from-sql-server","tag-how-to-debug-stored-procedure-in-visual-studio","tag-how-to-import-dll-in-sql-server","tag-how-to-write-c-code-in-sql-server","tag-import-dll-to-sql-server","tag-sql-clr-example","tag-sql-server-assembly-example","tag-sql-server-call-dll-from-stored-procedure","tag-sql-server-create-assembly","tag-sql-server-create-assembly-authorization","tag-the-assembly-is-authorized-when-either-of-the-following-is-true-the-database-owner-dbo-has-unsafe-assembly-permission-and-the-database-has-the-trustworthy-database-property-on","tag-trustworthy","tag-what-is-dll-in-sql","tag-what-is-sql-server-clr"],"aioseo_notices":[],"a3_pvc":{"activated":true,"total_views":4901,"today_views":0},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is CLR and How to import dll in sql server - Database Tutorials<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is CLR and How to import dll in sql server - Database Tutorials\" \/>\n<meta property=\"og:description\" content=\"CLR is a feature introduced with SQL Server 2005. Using the CLR (Common Language Runtime), you can perform a number of complex processes that you cannot do with TSQL using the .NET Framework, and you can import the dll into SQL Server and use it at the database level. You can also write stored procedures, &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Database Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-05T21:45:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-05T21:46:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-3.png\" \/>\n\t<meta property=\"og:image:width\" content=\"687\" \/>\n\t<meta property=\"og:image:height\" content=\"362\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"dbtut\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"dbtut\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/\"},\"author\":{\"name\":\"dbtut\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408\"},\"headline\":\"What is CLR and How to import dll in sql server\",\"datePublished\":\"2019-05-05T21:45:30+00:00\",\"dateModified\":\"2019-05-05T21:46:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/\"},\"wordCount\":870,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-3.png\",\"keywords\":[\"A .NET Framework error occurred during execution of user-defined routine or aggregate \\\"DiskFreeSpace_SP\\\"\",\"CREATE ASSEMBLY for assembly failed because assembly is not authorized for PERMISSION_SET = UNSAFE\",\"debug sql clr visual studio\",\"deploy clr function to sql server\",\"enable TRUSTWORTHY\",\"How do I debug CLR in stored procedure?\",\"How do you create a DLL file?\",\"how to call c# method from sql server\",\"how to debug stored procedure in visual studio\",\"How to import dll in sql server\",\"how to write c# code in sql server\",\"import dll to sql server\",\"sql clr example\",\"sql server assembly example\",\"sql server call dll from stored procedure\",\"sql server create assembly\",\"sql server create assembly authorization\",\"The assembly is authorized when either of the following is true: the database owner (DBO) has UNSAFE ASSEMBLY permission and the database has the TRUSTWORTHY database property on\",\"TRUSTWORTHY\",\"What is DLL in SQL?\",\"What is SQL Server CLR?\"],\"articleSection\":[\"MSSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/\",\"url\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/\",\"name\":\"What is CLR and How to import dll in sql server - Database Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-3.png\",\"datePublished\":\"2019-05-05T21:45:30+00:00\",\"dateModified\":\"2019-05-05T21:46:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#primaryimage\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-3.png\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-3.png\",\"width\":687,\"height\":362},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dbtut.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is CLR and How to import dll in sql server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dbtut.com\/#website\",\"url\":\"https:\/\/dbtut.com\/\",\"name\":\"Database Tutorials\",\"description\":\"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux\",\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dbtut.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dbtut.com\/#organization\",\"name\":\"dbtut\",\"url\":\"https:\/\/dbtut.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"width\":223,\"height\":36,\"caption\":\"dbtut\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408\",\"name\":\"dbtut\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g\",\"caption\":\"dbtut\"},\"description\":\"We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.\",\"sameAs\":[\"http:\/\/NurullahCAKIR\"],\"url\":\"https:\/\/dbtut.com\/index.php\/author\/dbtut\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is CLR and How to import dll in sql server - Database Tutorials","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"What is CLR and How to import dll in sql server - Database Tutorials","og_description":"CLR is a feature introduced with SQL Server 2005. Using the CLR (Common Language Runtime), you can perform a number of complex processes that you cannot do with TSQL using the .NET Framework, and you can import the dll into SQL Server and use it at the database level. You can also write stored procedures, &hellip;","og_url":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/","og_site_name":"Database Tutorials","article_published_time":"2019-05-05T21:45:30+00:00","article_modified_time":"2019-05-05T21:46:32+00:00","og_image":[{"width":687,"height":362,"url":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-3.png","type":"image\/png"}],"author":"dbtut","twitter_card":"summary_large_image","twitter_misc":{"Written by":"dbtut","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#article","isPartOf":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/"},"author":{"name":"dbtut","@id":"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408"},"headline":"What is CLR and How to import dll in sql server","datePublished":"2019-05-05T21:45:30+00:00","dateModified":"2019-05-05T21:46:32+00:00","mainEntityOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/"},"wordCount":870,"commentCount":0,"publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-3.png","keywords":["A .NET Framework error occurred during execution of user-defined routine or aggregate \"DiskFreeSpace_SP\"","CREATE ASSEMBLY for assembly failed because assembly is not authorized for PERMISSION_SET = UNSAFE","debug sql clr visual studio","deploy clr function to sql server","enable TRUSTWORTHY","How do I debug CLR in stored procedure?","How do you create a DLL file?","how to call c# method from sql server","how to debug stored procedure in visual studio","How to import dll in sql server","how to write c# code in sql server","import dll to sql server","sql clr example","sql server assembly example","sql server call dll from stored procedure","sql server create assembly","sql server create assembly authorization","The assembly is authorized when either of the following is true: the database owner (DBO) has UNSAFE ASSEMBLY permission and the database has the TRUSTWORTHY database property on","TRUSTWORTHY","What is DLL in SQL?","What is SQL Server CLR?"],"articleSection":["MSSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/","url":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/","name":"What is CLR and How to import dll in sql server - Database Tutorials","isPartOf":{"@id":"https:\/\/dbtut.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#primaryimage"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-3.png","datePublished":"2019-05-05T21:45:30+00:00","dateModified":"2019-05-05T21:46:32+00:00","breadcrumb":{"@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#primaryimage","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-3.png","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2019\/05\/Ads\u0131z-3.png","width":687,"height":362},{"@type":"BreadcrumbList","@id":"https:\/\/dbtut.com\/index.php\/2019\/05\/05\/what-is-clr-and-how-to-import-dll-in-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dbtut.com\/"},{"@type":"ListItem","position":2,"name":"What is CLR and How to import dll in sql server"}]},{"@type":"WebSite","@id":"https:\/\/dbtut.com\/#website","url":"https:\/\/dbtut.com\/","name":"Database Tutorials","description":"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux","publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dbtut.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/dbtut.com\/#organization","name":"dbtut","url":"https:\/\/dbtut.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","width":223,"height":36,"caption":"dbtut"},"image":{"@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408","name":"dbtut","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g","caption":"dbtut"},"description":"We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.","sameAs":["http:\/\/NurullahCAKIR"],"url":"https:\/\/dbtut.com\/index.php\/author\/dbtut\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/12012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/comments?post=12012"}],"version-history":[{"count":0,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/12012\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media\/12033"}],"wp:attachment":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media?parent=12012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/categories?post=12012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/tags?post=12012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}