locked
Adding framework reference to a CLR stored procedure RRS feed

  • Question

  • I'm using Visual Studio 2010 and don't seem to be able to add a reference to any of the .NET framework assemblies.  Am I limited in creating SQL CLR stored procedures to a set of assemblies?
    Tuesday, January 18, 2011 10:09 PM

Answers

All replies

  • Hello Ira,

    Thanks for your post.

    For your issue, as far as I know you can create a database object inside an instance of SQL Server that is programmed in an assembly created in the Microsoft .NET Framework common language runtime.

    You can first add a stored procedure item to the SQL CLR database project to create a stored procedure. And then deploy the CLR database project to machine that is running SQL Server.

    For more information about how to create and run a SQL Server Stored Procedure by using Common Language Run-time Integration, please refer to the followings articles:

    http://msdn.microsoft.com/en-us/library/5czye81z.aspx

    http://msdn.microsoft.com/en-us/library/ms190790.aspx

    And another walkthrough may help you a lot as well:

    http://msdn.microsoft.com/en-us/library/dd193408.aspx

    Thanks,


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, January 19, 2011 8:32 AM
    Moderator
  • Thanks for the response.  What I need to know is how can I add a project reference to another part of the .NET framework.  Specifically, I need to reference the System.DirectoryServices namespace.
    Wednesday, January 19, 2011 12:16 PM
  • I think I found the issue.  I didn't specify a server connection when creating the project so there are no namespaces shown.  Are the namespaces that show up the only ones that can be referenced?  I really need to access System.DirectoryServices.
    Wednesday, January 19, 2011 8:13 PM
  • Hello Ira,

    Sorry for the late reply. For your issue, I am afraid you can’t reference the dll from a SQL CLR project in the Visual Studio. Some system assemblies are not considered to be used inside SQL Server, because they can cause problem or not been fully tested in the SQL Server.

    If you want to use System DirectoryServices namespace, you can register the assembly manually in the SQL Server by running CREATE ASSEMBLY statement.

    Please check this article:

    http://msdn.microsoft.com/en-us/library/ms189524.aspx

    In addition, please also take a look at this thread:

    http://social.msdn.microsoft.com/Forums/en-US/sqlnetfx/thread/b6c9661c-2aaa-4041-8221-0138a18838fc

    Thanks,


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 24, 2011 10:16 AM
    Moderator
  • Hello Ira,

    I have marked my reply as answer. If you found it no help, please feel free to unmark it and let me know.

    Thanks,


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, February 4, 2011 7:50 AM
    Moderator
  • It that's the answer, that's the answer.

    Friday, February 4, 2011 1:55 PM