views:

126

answers:

1

I have read-only access to a database that was set up for a third-party, closed-source app. Once group of (hopefully) useful table functions only returns the error:

Failed to initialize the Common Language Runtime (CLR) v2.0.50727 with HRESULT 0x80131522. You need to restart SQL server to use CLR integration features. (severity 16)

But in theory, the third-party app should be able to use the function (either directly or indirectly), so I'm convinced I'm not setting things up right.

I'm very new to SQL Server, so I could be missing something obvious. Or I could be missing something really slight, I have no idea.

Here is an example of a query that returns the above error:

SELECT * FROM 
dbo.UncompressDataDateRange(4,'Apr 24 2010 12:00AM','Apr 30 2010 12:00AM')

Where the function takes three parameters:

  1. The Data Set (int) -- basically the data has 6 classifications, and the giant table this should be pulling from has a column to indicate which is which.

  2. startDate (smalldatetime)

  3. endDate (smalldatetime)

There are other, similar functions that expand on the same idea, all returning the same error.

Quick Note:

I'm not sure if this is relevant, but I was able to connect to the database via SQL Studio (but without the privs to script the functions as code), and a checked the dependency for the above sample function. It turns out that it is a dependent of a view that I have gotten to work, and that view is dependent of the larger, much-hairier data-table.

This makes me think I should somehow be pointing the function at the results of the view, but I'm not seeing any documentation that shows how that is done.

+1  A: 

The error message appears to hint that:

You need to restart SQL server to use CLR integration features

Perhaps the 3rd party installer enabled CLR integration, but was not able to restart SQL Server.

Andomar
If the 3rd-party app has been running just fine since February (whereas I just started poking at this last week), could this still be the case? Does my user account need to explicitly have CLR enabled? Bear in mind it took me two years of me parsing csv files ouput from this 3rd-party app before I gained enough cred to finally get direct access to its DB, so I have to be VERY sure that I've eliminated any other possibility before I start making requests to people well above my pay-grade for server restarts and the like just to see if fixes the problem.
Anthony
@Anthony: CLR integration is about importing .NET code (like C#) into SQL Server. If the install is 3 years old, restarting seems an unlikely fix. The error message seems clear enough though; perhaps CLR integration is not enabled. At the very least, that means the code has never worked.
Andomar
So if the code has never worked, that would suggest the app is using some other functions. Bummer. The App has been in place for at least three years, but it was updated to a newer version a few months ago, so it's quite possible some .NET action has been added. At the risk of sounding totally out of the loop, when you say "importing .NET code" into the SQL Server, do you mean within the function definition itself? Or does the function expect me to pass something in C♯ to it?
Anthony
I also found a MS support forum thread that suggested that this error can emerge when security policies change because the server is trying to pull an assembly that doesn't exist. This makes NO sense to me, but since this user account was added so that I could get access, would this be something worth bringing to the sysadmin, or would it sound like I was throwing out misread jargon read somewhere?
Anthony
@Anthony: "importing .NET code" means instructing SQL Server how to load and run a .NET assembly (a .dll file.) It makes sense that you get an error if you change security settings in a way that prevents SQL Server from loading the library. I'd present the error message with the way to reproduce it, and ask for help. We are all idiots at times, certainly in IT, so that by itself shouldn't be something to be afraid of :)
Andomar
Turns out we were both right. There was a scheduled failover this weekend, which the sysadmin said should fix it. After the failover, it explicitly said the assembly didn't exist, etc. thanks for the pep talk on asking for help.
Anthony