Where Are Assembly Dependencies (on SQL Objects) Stored?
Oct 4, 2007
I've created an assembly in Adventureworks, and created a sproc that references a function inside the assembly. All works well with the asssembly and proc.
I know that I can't drop the assembly without first dropping the sproc, but I can't find where the dependency information is stored. sp_depends, sys.sql_dependencies, etc, all come up empty for the assembly, and when I run sp_depends on the SQL sproc object, I get:
"Object does not reference any object, and no objects reference it."
Clearly that's not the case, since if I attempt to drop the assembly, I get the expected error 6590: "DROP ASSEMBLY failed because 'ProcTest' is referenced by object 'uspGetStuffFromAssembly' "
Any idea where this is being stored?
--
Chris Randall
cfrandall@google'smail.com
blogs.ameriteach.com/chris-randall
My reporting server 2005 frequently throws error below. The PC hosting reporting server has .net framework 1.1 and 2.0 installed, and it does not have SQL server installed. The 2 databases used by reporting server are in another PC. Please help. w3wp!webserver!1!3/14/2007-07:01:35:: i INFO: Reporting Web Server started w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing ConnectionType to '0' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing IsSchedulingService to 'True' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing IsNotificationService to 'True' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing IsEventService to 'True' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing PollingInterval to '10' second(s) as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing WindowsServiceUseFileShareStorage to 'False' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing MemoryLimit to '60' percent as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing RecycleTime to '720' minute(s) as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing MaximumMemoryLimit to '80' percent as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing MaxAppDomainUnloadTime to '30' minute(s) as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing MaxQueueThreads to '0' thread(s) as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing IsWebServiceEnabled to 'True' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing MaxActiveReqForOneUser to '20' requests(s) as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing MaxScheduleWait to '5' second(s) as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing DatabaseQueryTimeout to '120' second(s) as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing ProcessRecycleOptions to '0' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing RunningRequestsScavengerCycle to '60' second(s) as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing RunningRequestsDbCycle to '60' second(s) as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing RunningRequestsAge to '30' second(s) as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing CleanupCycleMinutes to '10' minute(s) as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing DailyCleanupMinuteOfDay to default value of '120' minutes since midnight because it was not specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing WatsonFlags to '1064' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing WatsonDumpOnExceptions to 'Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException,Microsoft.ReportingServices.Modeling.InternalModelingException' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing WatsonDumpExcludeIfContainsExceptions to 'System.Data.SqlClient.SqlException,System.Threading.ThreadAbortException' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing SecureConnectionLevel to '0' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing DisplayErrorLink to 'True' as specified in Configuration file. w3wp!library!1!3/14/2007-07:01:35:: i INFO: Initializing WebServiceUseFileShareStorage to 'False' as specified in Configuration file. w3wp!resourceutilities!1!3/14/2007-07:01:35:: i INFO: Reporting Services starting SKU: Standard w3wp!resourceutilities!1!3/14/2007-07:01:35:: i INFO: Evaluation copy: 0 days left w3wp!resourceutilities!1!3/14/2007-07:01:35:: i INFO: Running on 2 physical processors, 4 logical processors w3wp!runningjobs!1!3/14/2007-07:01:35:: i INFO: Database Cleanup (Web Service) timer enabled: Next Event: 600 seconds. Cycle: 600 seconds w3wp!runningjobs!1!3/14/2007-07:01:35:: i INFO: Running Requests Scavenger timer enabled: Next Event: 60 seconds. Cycle: 60 seconds w3wp!runningjobs!1!3/14/2007-07:01:35:: i INFO: Running Requests DB timer enabled: Next Event: 60 seconds. Cycle: 60 seconds w3wp!runningjobs!1!3/14/2007-07:01:35:: i INFO: Memory stats update timer enabled: Next Event: 60 seconds. Cycle: 60 seconds w3wp!library!1!03/14/2007-07:01:35:: i INFO: Catalog SQL Server Edition = Standard w3wp!library!1!3/14/2007-07:01:36:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.ReportingServices.ProcessingCore, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. Access is denied. File name: 'Microsoft.ReportingServices.ProcessingCore, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' at Microsoft.ReportingServices.Library.CreateNewSessionAction.Save() at Microsoft.ReportingServices.WebServer.ReportExecutionService.LoadReport(String Report, String HistoryID, ExecutionInfo& executionInfo) at Microsoft.Reporting.WebForms.ServerReport.GetExecutionInfo() at Microsoft.Reporting.WebForms.ServerReport.SetParameters(NameValueCollection parameters) at Microsoft.ReportingServices.WebServer.ReportViewerHost.OnLoad(EventArgs e)
WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLMSoftwareMicrosoftFusion!EnableLog].
--- End of inner exception stack trace --- w3wp!library!1!3/14/2007-07:01:36:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.1Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson w3wp!library!a!3/14/2007-07:11:35:: i INFO: Cleaned 0 batch records, 0 policies, 0 sessions, 0 cache entries, 0 snapshots, 0 chunks, 0 running jobs, 0 persisted streams w3wp!library!9!3/14/2007-07:21:35:: i INFO: Cleaned 0 batch records, 0 policies, 0 sessions, 0 cache entries, 0 snapshots, 0 chunks, 0 running jobs, 0 persisted streams w3wp!library!1!3/14/2007-07:31:35:: i INFO: Cleaned 0 batch records, 0 policies, 0 sessions, 0 cache entries, 0 snapshots, 0 chunks, 0 running jobs, 0 persisted streams w3wp!library!8!3/14/2007-07:33:55:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.ReportingServices.ProcessingCore, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. Access is denied. File name: 'Microsoft.ReportingServices.ProcessingCore, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' at Microsoft.ReportingServices.Library.CreateNewSessionAction.Save() at Microsoft.ReportingServices.WebServer.ReportExecutionService.LoadReport(String Report, String HistoryID, ExecutionInfo& executionInfo) at Microsoft.Reporting.WebForms.ServerReport.GetExecutionInfo() at Microsoft.Reporting.WebForms.ServerReport.SetParameters(NameValueCollection parameters) at Microsoft.ReportingServices.WebServer.ReportViewerHost.OnLoad(EventArgs e)
WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLMSoftwareMicrosoftFusion!EnableLog].
--- End of inner exception stack trace --- w3wp!library!8!3/14/2007-07:34:25:: i INFO: Exception dumped to: C:Program FilesMicrosoft SQL ServerMSSQL.1Reporting ServicesLogFiles flags= ReferencedMemory, AllThreads, SendToWatson w3wp!library!1!3/14/2007-07:41:35:: i INFO: Cleaned 0 batch records, 0 policies, 0 sessions, 0 cache entries, 0 snapshots, 0 chunks, 0 running jobs, 0 persisted streams w3wp!library!a!3/14/2007-07:42:44:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.ReportingServices.ProcessingCore, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. Access is denied. File name: 'Microsoft.ReportingServices.ProcessingCore, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' at Microsoft.ReportingServices.Library.CreateNewSessionAction.Save() at Microsoft.ReportingServices.WebServer.ReportExecutionService.LoadReport(String Report, String HistoryID, ExecutionInfo& executionInfo) at Microsoft.Reporting.WebForms.ServerReport.GetExecutionInfo() at Microsoft.Reporting.WebForms.ServerReport.SetParameters(NameValueCollection parameters) at Microsoft.ReportingServices.WebServer.ReportViewerHost.OnLoad(EventArgs e)
WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLMSoftwareMicrosoftFusion!EnableLog].
I use SQL code snippet to attach the CLR assembly (dll) to the SQL Server Express
CREATE ASSEMBLY [DatabaseAndImages] AUTHORIZATION [dbo] FROM 'C:CLR_File.dll' WITH PERMISSION_SET = SAFE
That file content CRL Codes for 10 Stored Procedures & 3 UDT & 5 Functions & 6 Triggers As you can see it's content large amount of DB objects !!
My Question is .. Is there any simple way can I use it to extract or automatic create all that Objects in the Database without use separate SQL Statement for each one ??
By Example , I will use this SQL statement to create the sp_AddImage that already located inside the CLR dll file
CREATE PROCEDURE [dbo].[sp_AddImage] @ImageID [uniqueidentifier], @ImageFileName [nvarchar](max), @Image [varbinary](max) WITH EXECUTE AS CALLER AS EXTERNAL NAME [DatabaseAndImages].[StoredProcedures].[sp_AddImage]
But as you know .. I have many objects .. and I am in development phase and I will do change to that object many time and also may I will add much more €¦
I thing it's not good to write SQL Statement for each object and do changes every time when I change the object definition
Is there any one line of SQL statement can I use it to automatically create and extract all the objects inside the assembly ?? Or is there any way to do that Issue by simple operation ??
I need to write a code for remove dependencies between Table1.Prikey and Table2.Idand add dependencies between Table1.Prikey and Table3.Id how to write the code? please help .. thank you very much
Hi All, How to get all the Dependencies of a Stored Procedure? Dependencies may exists in other databases also. For Example Stored procedure "sp_Employee" exists in the DB "Employee" This SP calling the another SP exists in another DB "Organization" You help would be appreciated.. RegardsGokul
I have 40 stored procedures in a database. A table X is called by some procedures. How to check which procedure call table X, and how many procedures call table X? Thanks
I work with February CTP of SqlServer 2008. I have an Assembly with several UDTs inside. Version of assembly is 1.0.* I use CREATE ASSEMBLY statement to register this assembly, and it runs without any errors. Then I rebuild CLR solution without doing any changes in source code. In that case the only difference between new and old assemblies is version (difference in fourth part of version). Then I try to update assembly in SqlServer. I use ALTER ASSEMBLY <name> FROM <path> WITH PERMISSION_SET = UNSAFE, UNCHECKED DATA statement for this. Statement runs with error: Msg 6509An error occurred while gathering metadata from assembly €˜<Assembly name>€™ with HRESULT 0x1. I found the list of condition for ALTER ASSEMBLY in MSDN: ALTER ASSEMBLY statement cannot be used to change the following: · The signatures of CLR functions, aggregate functions, stored procedures, and triggers in an instance of SQL Server that reference the assembly. ALTER ASSEMBLY fails when SQL Server cannot rebind .NET Framework database objects in SQL Server with the new version of the assembly. · The signatures of methods in the assembly that are called from other assemblies. · The list of assemblies that depend on the assembly, as referenced in the DependentList property of the assembly. · The indexability of a method, unless there are no indexes or persisted computed columns depending on that method, either directly or indirectly. · The FillRow method name attribute for CLR table-valued functions. · The Accumulate and Terminate method signature for user-defined aggregates. · System assemblies. · Assembly ownership. Use ALTER AUTHORIZATION (Transact-SQL) instead. Additionally, for assemblies that implement user-defined types, ALTER ASSEMBLY can be used for making only the following changes: · Modifying public methods of the user-defined type class, as long as signatures or attributes are not changed. · Adding new public methods. · Modifying private methods in any way.
But I haven€™t done any changes in source code, so new version of assembly satisfies all this conditions. What could be the reason for such behavior? P.S. I€™ve got the same error, if I add or change any method in assembly before rebuilding.
I was playing around with the CLR in writing assemblies for the sql server 2005 stored procedure. I guess the example i found was for the beta version This line is from the beta but no longer works. Any ideas what will fix this. There is no longer GetCommand property. SqlCommand cmd = SqlContext.GetCommand();
Example public partial class StoredProcedures{[Microsoft.SqlServer.Server.SqlProcedure] public static void StoredProcedure1() { // Put your code here SqlCommand cmd = SqlContext.GetCommand(); cmd.CommandText="select firstname + ' ' + lastname + as [name] from person.contact"; SqlDataReader rdr = cmd.ExecuteReader(); SqlPipe sp = SqlContext.GetPipe(); sp.Send(rdr); }};
I am trying to get a function I created in VB 5 for Access and Excel to work in SQL 2005. I was able to update the old VB code to work in VB 2005. I compiled and made a .dll, and I was able to register the new Assembly in SQL Server. When I try to create the Function, I get an error:
AS EXTERNAL NAME FluidProps.[FluidProps.FluidProperties.Fluids].Temperature
Error returned:
Msg 6573, Level 16, State 1, Procedure Temperature, Line 21
Method, property or field 'Temperature' of class 'FluidProps.FluidProperties.Fluids' in assembly 'FluidProps' is not static.
Here is the code (part of it) in the VB class:
Header:
Imports Microsoft.SqlServer.Server
Imports System.Data.SqlClient
Imports System.Runtime.InteropServices
Imports System.Security
Imports System.Security.Permissions
Namespace FluidProperties
'Option Strict Off
'Option Explicit On
Public Partial Class Fluids
Function:
Function Temperature(ByRef FluidName As Object, ByRef InpCode As Object, ByRef Units As Object, ByRef Prop1 As Object, Optional ByRef Prop2 As Object = Nothing) As Object
If I change the Function Temperature to Static, I get an error that functions cannot be Static. Its been a long time since I created the code and am having a hard time in my older age of getting the cobwebs out to make it work.
I have no problem getting the function to work if I call it from a VB form....so what do I need to do to get it to work on data in my SQL server?
I am having trouble with the following and appreciate any help.Thanks in advanced.
I have created an assembly to delete records in exchange (which works fine when testing it in debug mode). I then create the assembly in SQL server 2005(tried both unsafe and external access btw), and then i create a stored procedure calling the assembly.
Now my error occurs when i try to execute this stored procedure in SQL Server. I get the following...
Msg 6522, Level 16, State 1, Procedure sp_DeleteExchApp, Line 0A .NET Framework error occurred during execution of user defined routine or aggregate 'sp_DeleteExchApp': System.Security.SecurityException: System.Security.Permissions.SecurityPermissionSystem.Security.SecurityException: at App_Delete.eSay.AppointmentDelete.DeleteAppointment(Guid GUID).(1 row(s) affected)
Now when i have looked around the web, i have come accross people saying that it is to do with the assembly trying to access something it does not have permission for. But i cant figure out what that is or why it is throwing an error.
The code for the assembly is as follows:
Public Shared Sub DeleteAppointment(ByVal GUID As System.Guid) Dim CalendarURL As String Dim ItemURL As String Dim Rs As New ADODB.Recordset Dim Rec As New ADODB.Record Dim Conn As New ADODB.Connection Dim iAppt As New Appointment Dim Target As String Dim strCRMGUID As String Dim strGUID As String Dim sSQL As String Dim Check As String strCRMGUID = GUID.ToString 'Using the Exchange OLE DB provider CalendarURL = "file://./backofficestorage/esay-solutions.co.uk/public folders/Office Diary" 'Open a recordset for the items in the calendar folder Rec.Open(CalendarURL) Rs.ActiveConnection = Rec.ActiveConnection sSQL = "SELECT ""DAV:href"", " & _ " ""urn:schemas:calendar:location"", " & _ " ""urn:schemas:calendar:dtstart"", " & _ " ""urn:schemas:calendar:dtend"", " & _ " ""urn:schemas:httpmail:textdescription"" " & _ "from scope('shallow traversal of """ & CalendarURL & """')" Rs.Open(sSQL, Rec.ActiveConnection, CursorTypeEnum.adOpenUnspecified, LockTypeEnum.adLockOptimistic, 1) 'Enumerate the recordset, checking each item's location If Rs.RecordCount > 0 Then Rs.MoveFirst() Do Until Rs.EOF 'get the location of each item Check = Rs.Fields(CdoHTTPMail.cdoTextDescription).Value strGUID = StripGUID(Check) 'test for desired location If (strGUID = strCRMGUID) Then Rs.Delete() End If Rs.MoveNext() Loop End If End Sub Private Shared Function StripGUID(ByVal i_strAppDescription As String) As String 'Function to strip the GUID from the message field Dim r As Integer Dim SearchChar As String Dim testPos As Integer Dim GUID As String SearchChar = "**¦" testPos = InStr(i_strAppDescription, SearchChar) testPos = testPos + 3 If testPos > 0 Then GUID = Mid(i_strAppDescription, testPos) End If StripGUID = GUID End Function End ClassEnd Namespace
Is it possible to load an assembly either from a byte array or from the disk at runtime from a CLR stored procedure.
I have created a stored procedure that needs to load different assemblies depending on a query and then invokes a method (called execute() passing a string query as a parameter).
From debugging the CLR stored procedure in .NET I have found that it is this line that creates an error:
Assembly myAssembly= Assembly.Load()
It doesnt matter if I attempt to load the assembly from it's byte array or from a file location, it always gives the following error:
Msg 6522, Level 16, State 1, Procedure runQuery, Line 0A .NET Framework error occurred during execution of user defined routine or aggregate 'runQuery': System.IO.FileLoadException: LoadFrom(), LoadFile(), Load(byte[]) and LoadModule() have been disabled by the host.System.IO.FileLoadException: at System.Reflection.Assembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection) at System.Reflection.Assembly.Load(Byte[] rawAssembly) at ClientInterface.RunInterface(String queryName, String parameters, String& returnValue)
It works perfectly if I run it using a mock up front end app it just seems to be sql server that doesnt like it.
I previously had an ASP.NET 1.1 site running on my IIS 6.0 server (not the default website) with Reporting Services running in a subdirectory of that website. I recently upgraded to ASP.NET 2.0 for my website and was greeted with an error when trying to view a report. The error was very non-descript, but when I checked the server logs, it recorded the details as "It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process."
First of all, I could not figure out where and how to do this. Secondly, I decided to try to also change the Reporting Services folders to run ASP.NET 2.0 and when I did, I was greeted with the following message when attempting to view a report:
"Failed to load expression host assembly. Details: StrongName cannot have an empty string for the assembly name."
I am a bit paranoid about what I just did to my SQL Server 2005 with this CLR experiment.
I created a Class Lib in C# called inLineLib that has a class Queue which represents an object with an ID field.
in another separate namespace called inLineCLRsql, I created a class called test which will hold the function to be accessed from DB, I referenced and created an instances of the Queue class, and retrieve it's ID in a function called PrintMessage.
to access this from the db, I attempted to create an assembley referencing inLineCLRsql.dll. This didn't work as it complained about inLineLib assembly not existing in the db. I then attempted to create an assembley for inLineLib but it barfed saying System.Management assembly not created.
so what I did is (and this is where I need to know if I just ruined sql server or not):
1- ALTER DATABASE myDB SET TRUSTWORTHY ON;.
2- CREATE ASSEMBLY SystemManagement
FROM 'C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Management.dll'
WITH PERMISSION_SET = UNSAFE
3- CREATE ASSEMBLY inLineLibMaster
FROM 'D:inLineServerinLineLibinDebuginLineLib.dll'
WITH PERMISSION_SET = unsafe
4- and finally
CREATE ASSEMBLY inLineLib
FROM 'D:inLineServerCLRSQLinlineCLRsqlinDebuginlineCLRsql.dll'
WITH PERMISSION_SET = SAFE
Everything works after those steps (which took some trial and error). I can create a sproc like:
CREATE PROC sp_test AS
EXTERNAL NAME inLineLib.[inlineCLRsql.test].PrintMessage
and it returns the Queue ID
Is there anything unadvisable about the steps above?
I am developing a managed stored procedure in VS.NET 2005 and I am trying to add a reference to an user developed assembly (not a system one) but adding a reference to it is not possible as it doesnt let me import assemblies but rather reference the few limited ones in a list. Why is this??
We have written a test CRL stored procedure to test replacing one of our complex stored procedures but can€™t get it deployed to our SQL server that hosts a mirrored configuration of our production database (very locked down). It works fine on our development instances (not very locked down). It only references the default assemblies that were added when we created the project. All it does is use Context Connection=true to get data, loops though some records and returns the data using SQLContext. CLR is enabled on SQL server, the assembly is strongly signed, and we tried deploy using the binary string with the SAFE setting.
CREATE ASSEMBLY for assembly 'SQLCLRTest2' failed because assembly 'SQLCLRTest2' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message [ : SQLCLRTest2.StoredProcedures::GetLift][mdToken=0x600001e] Type load failed. [token 0x02000008] Type load failed.
I need to understand the permissions that a CLR stored procedure needs when it accesses tables. In a dbo TSQL stored procedure it has owner permissions on all dbo tables, so there is no need to grant permissions on tables to the database user.
Some developers recently implemented a CLR stored procedure that returned an error with update permission denied on table name. Once I granted the user account update permission on that table, it was able to execute OK.
I have been looking for a good explanation for the way the permissions to database objects need to be setup for CLR stored procedures. For example, could I have said to modify the procedure to use the EXECUTE AS clause, instead of granting the user account direct permission on the table? Does anyone have any links to good articles on this subject?
Edit: I have a feeling I'm on my own trying to figure out how this works. I've been searching the web for hours, and I haven't found anything that directly addresses this.
I am trying to deploy a Database Project with Visual Studio 2005 and SQL Server 2005 Standard. I import €œSystem.IO€? and have therefore set the permission levels to EXTERNAL_ACCESS.
I am receiving the same error message that many folks have received.
CREATE ASSEMBLY for assembly 'Images' failed because assembly 'Images' is not authorized for PERMISSION_SET = EXTERNAL_ACCESS. The assembly is authorized when either of the following is true: the database owner (DBO) has EXTERNAL ACCESS 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 EXTERNAL ACCESS ASSEMBLY permission. If you have restored or attached this database, make sure the database owner is mapped to the correct login on this server. If not, use sp_changedbowner to fix the problem. Images.
My CLR access is €œon€?
I have tried
1) From master run: GRANT EXTERNAL ACCESS ASSEMBLY to [BuiltinAdministrators]. 2) From master run: GRANT EXTERNAL ACCESS ASSEMBLY to €œMy Windows Authentication ID€?. 3) Run ALTER DATABASE MYDATABASE SET TRUSTWORTHY ON 4) In Visual Studio .NET 2005 Set the permission levels to €˜external€™ 5) Tried BuiltinAdministrators and my SQL Server Windows Authenticated Login ID for the ASSEMBLY OWNER.
I can compile BUT NOT DEPLOY
Any help would be greatly appreciated. Regards Steve
I was trying to understand how VS.NET2005 was deploying .NET CLR assemblies to SQL2005 so I ran a trace and found some interesting results.
VS.NET creates some SQL that looks pretty interesting:
CREATE ASSEMBLY [AssemblyNameHere] FROM 0x4D5A90000300000004000000FFFF000......<continue binary data> WITH PERMISSION_SET = EXTERNAL_ACCESS
Boy howdy!
I have tried to reproduce this and create my own deployment application but I cant figure out how they create this binary stream. The info in BOL is not much help and I have not found any samples anywhere on how to create this stream in c#.
While trying to execute a stored procedure I am getting error that 'SELECT permission denied on table .......' The DBA has given execute permission for the sp and still the same error. What needs to be done. When permissions are given through the SP it implies that the objects are given permissions ?
Putting in db_datareader group will give permission to read from all tables across all the databases in the server. We want that the user should be able to read data from only those tables called in the sp. Normally in SQL 2000 we used to give EXECUTE permissions to the sp only. This in turn would be enough for that user to get data while executing the sp.
Hi All, I am trying my hand at SQL CLR. I want to know one thing which I'm not able to get from anywhere. Suppose I've a C# class like Student. I create an object of this class and push its values into database. Instead of pushing individual property values to database I want to pass the Student object itself or maybe an array or list etc. Kindly help me if it is possible. Regards
Could anybody tell me how can I find all the database objects that are used in /referenced by/called by/dependent on a given stored procedure? In other words, I am looking for something like a stored procedure or a function that takes as input the name of a stored procedure and outputs all the names of the tables, functions, procedures, cursors and etc. database objects that are used in that procedure. Could you please give me suggestions or possible answers for this?
please help newbieI need to create a lot of objects the same type (let's say: schemas)I wish to use paramerized block in loop to do so.- how to put names of my objects to such control-flow?belss you for help
I'm unable to copy my Stored Procedures from one database to another. I'm using mixed mode authentication. I have set CopyAllStoredProcedures to True, DropObjectsFirst to True and CopySchema to True.
Nothing gets copied. I have followed many web sites that say Transfer SQL Server Objects Task is broken. Is this true and I should give up?
Also, I'm on SQL 2005 SP2 which appears to be the latest and I assume is the update for SSIS? yes ?
Thanks for any help
[Transfer SQL Server Objects Task] Error: Execution failed with the following error: "ERROR : errorCode=-1073548784 description=Executing the query "CREATE PROCEDURE [dbo].[del_Admin_RemoveContractorFromContract] @ContractID int, @ContractorID int AS DELETE FROM CONTRACTOR_CONTRACTS WHERE CONTRACT_ID = @ContractID AND CONTRACTOR_ID = @ContractorID DELETE FROM CONTRACTOR_USER_CONTRACTS WHERE CONTRACT_ID = @ContractID AND CONTRACTOR_ID = @ContractorID " failed with the following error: "There is already an object named 'del_Admin_RemoveContractorFromContract' in the database.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. helpFile= helpContext=0 idofInterfaceWithError={8BDFE893-E9D8-4D23-9739-DA807BCDC2AC}". Warning: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
passing serialised objects to a stored procedure for the purpose of data inserts. I see this as being a way to handle multiple row inserts efficiently.
However, in my limited use of XML data I am not so sure how to link the data when I have a dependency on another "object" within the serialised XML.
Below is a code snippet showing what I have so far.
The first insert statement works fine - but how to retrieve the identifier created by the DB - I want to use an SQL statement that finds the record in the table based on the XML representation (of the PluginInfo), allowing me to insert the ConfigurationInfo with the correct reference to the PluginInfo
DECLARE @Config NVARCHAR(MAX) DECLARE @Handle AS INT DECLARE @TransactionCount AS INT SELECT @Config = ' <ConfigurationDirectory > <ConfigurationInfo groupKey="Notifications" sectionKey="App.Customization.PluginInfo"
How can get an object's dependencies in SQL Server. For example it I have written a procedure which accesses some tables inside it then the procedure is said to be dependent on that table. Or one procedure might call another procedure and hence dependent.
Can I know an object's dependent objects from any system table. I think Oracle has a table USER_DEPENDENCIES which provides this info (I may be wrong :-().
The previous post regarding dependencies reminded me of another bugger I comeup with from time to time. SQL Server allows us to rename objects via asystem stored procedure (I usually use an ADP front-end that presumably callsthe same procedure), but after the rename, I find singnificant strangeness.For instance, triggers are still connected to the tables, but the trigger textstill refers to the old table name. Views and stored procedures dependent onthe table are broken, and are not fixed by even by restarting the server,though I thought the cached plans were supposed to be dumped on shut-down,then recreated on demand later.Is there some tool or technique to rename a table and automatically detect andproperly drop/rebuild dependent triggers, views, stored procedures,relationships, and anything else I'm not thinking of?Oh yeah, and there are extended properties to deal with as well, but I guessthat's intractible unless we know what client build them (e.g. Access ADP),and what it expects to be recorded there, but I suppose it would be nice tojust dump them rather than leave them there possibly corrupted from a client'spersective.
I am currently using SQLCacheDependencies to help me manage my cache in an ASP.NET application that is hosted across a web farm. This utilises the SQL Server 2005 service broker feature.
I have implemented this and is currently working but i have a few questions i want to clear up and i hope someone can assist me in that.
1/. I am starting the broker service by using the command System.Data.SqlClient.SqlDependency.Start( <connection string> ); I currently have that piece of code running when the application starts in the global.asax file. What i want to know is will all SQL queries that hit the database register a notification? Is is possible to only have a selected query register a notification?
In my web application only a handful of database queries require a sqlcachedependency to be created. I dont want all queries to be registering a notification as that will place a burden on my backend server.
1/. So does all queries register a notification once the broker is started? 2/. Is there a way to only tell selected queries to register a notification? 3/. When a cache object is invalidated because of a absolute and slidingscaletimeout, does the existing sqlconnection for that service broker get disposed?