{"id":1976,"date":"2020-07-04T15:53:28","date_gmt":"2020-07-04T15:53:28","guid":{"rendered":"http:\/\/www.theSQLReport.com\/?p=1976"},"modified":"2020-07-04T15:55:31","modified_gmt":"2020-07-04T15:55:31","slug":"msg-7302-level-16-state-1-with-a-linked-server","status":"publish","type":"post","link":"http:\/\/www.theSQLReport.com\/?p=1976","title":{"rendered":"Msg 7302, Level 16, State 1 with a Linked Server"},"content":{"rendered":"<p class=\"yiv8006685110MsoNormal\"><strong>Problem:<\/strong><\/p>\n<p class=\"yiv8006685110MsoNormal\">A developer reach out to me about an error they were getting when attempting to run a stored procedure that used a linked server to pull data from an Oracle database using an Active Directory login.\u00a0 This was happen on the production database server, however this stored procedure worked on the development database server.<\/p>\n<p class=\"yiv8006685110MsoNormal\"><strong>Error Message:<\/strong><\/p>\n<p class=\"yiv8006685110MsoNormal\">Msg 7302, Level 16, State 1, Procedure \u2026, Line \u2026 [Batch Start Line ..]Cannot create an instance of OLE DB provider &#8220;OraOLEDB.Oracle&#8221; for linked server &#8220;\u2026&#8221;.<\/p>\n<p class=\"yiv8006685110MsoNormal\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/MSG7302Level16State1.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1977 size-full\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/MSG7302Level16State1.jpg\" alt=\"Msg 7302, Level 16, State 1\" width=\"1028\" height=\"146\" \/><\/a><\/p>\n<p class=\"yiv8006685110MsoNormal\">Part of the problem when working with linked servers is that SQL Server stores some of its information in the Window Registry, and can not easily be verified.<\/p>\n<p class=\"yiv8006685110MsoNormal\">The provider for the Oracle OLE DB needs to have the \u201cAllowInProcess\u201d enabled, which again does this with as a DWORD Value in the registry.<\/p>\n<p class=\"yiv8006685110MsoNormal\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_DWORD_Value.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1980 size-full\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_DWORD_Value.jpg\" alt=\"&quot;AllowInProcess\u201d enabled as a DWORD Value in the registry.\" width=\"1013\" height=\"365\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_DWORD_Value.jpg 1013w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_DWORD_Value-300x108.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_DWORD_Value-768x277.jpg 768w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_DWORD_Value-210x76.jpg 210w\" sizes=\"(max-width: 1013px) 100vw, 1013px\" \/><\/a><\/p>\n<p class=\"yiv8006685110MsoNormal\">Thankfully, I don\u2019t have to use the registry editor to find the value.\u00a0 There is a extended stored procedure that lets me view this.<\/p>\n<p class=\"yiv8006685110MsoNormal\">On my SQL Server 2016 development database server I ran the following:<\/p>\n<pre class=\"yiv8006685110MsoNormal\">EXECUTE master.sys.xp_regread\r\n\u00a0\u00a0\u00a0 'HKEY_LOCAL_MACHINE',\r\n\u00a0\u00a0\u00a0 'SOFTWARE\\Microsoft\\Microsoft SQL Server\\MSSQL13.MSSQLSERVER\\Providers\\OraOLEDB.Oracle\\',\r\n\u00a0\u00a0\u00a0 'AllowInProcess';<\/pre>\n<p class=\"yiv8006685110MsoNormal\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_Enabled.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1981 size-full\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_Enabled.jpg\" alt=\"AllowInProcess\u201d enabled\" width=\"990\" height=\"352\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_Enabled.jpg 990w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_Enabled-300x107.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_Enabled-768x273.jpg 768w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_Enabled-210x75.jpg 210w\" sizes=\"(max-width: 990px) 100vw, 990px\" \/><\/a><\/p>\n<p class=\"yiv8006685110MsoNormal\">Notice that the registry key is version dependent on the version of SQL Server running.\u00a0 I am able to see that with the value of \u201c1\u201d, that provider for the Oracle OLE DB \u201cAllowInProcess\u201d is enabled.<\/p>\n<p class=\"yiv8006685110MsoNormal\">However when I ran the same SQL on my production database server, I see that provider for the Oracle OLE DB \u201cAllowInProcess\u201d was not found.<\/p>\n<p class=\"yiv8006685110MsoNormal\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_NotEnabled.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1982 size-full\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_NotEnabled.jpg\" alt=\"\u201cAllowInProcess\u201d was not enabled\" width=\"938\" height=\"326\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_NotEnabled.jpg 938w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_NotEnabled-300x104.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_NotEnabled-768x267.jpg 768w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/AllowInProcess_NotEnabled-210x73.jpg 210w\" sizes=\"(max-width: 938px) 100vw, 938px\" \/><\/a><\/p>\n<p class=\"yiv8006685110MsoNormal\"><strong>Resolution:<\/strong><\/p>\n<p class=\"yiv8006685110MsoNormal\">To enable the \u201cAllowInProcess\u201d for the provider for the Oracle OLE DB, I ran the \u201csp_MSset_oledb_prop\u201d stored procedure:<\/p>\n<pre class=\"yiv8006685110MsoNormal\">EXEC master.dbo.sp_MSset_oledb_prop N'OraOLEDB.Oracle', N'AllowInProcess', 1;\r\nGO<\/pre>\n<p class=\"yiv8006685110MsoNormal\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1978 size-full\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop.jpg\" alt=\"EXEC master.dbo.sp_MSset_oledb_prop N'OraOLEDB.Oracle', N'AllowInProcess', 1\" width=\"808\" height=\"164\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop.jpg 808w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop-300x61.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop-768x156.jpg 768w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop-210x43.jpg 210w\" sizes=\"(max-width: 808px) 100vw, 808px\" \/><\/a><\/p>\n<p class=\"yiv8006685110MsoNormal\">The developer tested &amp; now will be able to use all its stored procures with that OLE provider.<\/p>\n<p class=\"yiv8006685110MsoNormal\">Please note not to just cut &amp; past with the error, make sure that OLE DB provider in the error message is the same in the SQL that is run to enable the \u201cAllowInProcess\u201d.\u00a0 My first attempt was a lazy cut &amp; paste from Google, and I enabled the \u201cAllowInProcess\u201d for \u201cMicrosoft.ACE.OLEDB.12.0\u201d provider.<\/p>\n<p class=\"yiv8006685110MsoNormal\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop_OLE_provider.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1979 size-full\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop_OLE_provider.jpg\" alt=\"OLE DB provider in the error message is the same in the SQL\" width=\"1292\" height=\"352\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop_OLE_provider.jpg 1292w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop_OLE_provider-300x82.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop_OLE_provider-1024x279.jpg 1024w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop_OLE_provider-768x209.jpg 768w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2020\/06\/sp_MSset_oledb_prop_OLE_provider-210x57.jpg 210w\" sizes=\"(max-width: 1292px) 100vw, 1292px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem: A developer reach out to me about an error they were getting when attempting to run a stored procedure that used a linked server to pull data from an &hellip; <a class=\"readmore\" href=\"http:\/\/www.theSQLReport.com\/?p=1976\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":1977,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1976","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql-server"],"_links":{"self":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/1976"}],"collection":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1976"}],"version-history":[{"count":2,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/1976\/revisions"}],"predecessor-version":[{"id":1984,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/1976\/revisions\/1984"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/media\/1977"}],"wp:attachment":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1976"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}