Wednesday, March 7, 2012

How to call .NET framework library within SPROC

Hi, with SQL server 2005.

Could I write a SPROC with C# or VB.NET that calls methods within the .net library or

Could I package a .net methods into a SPROC to let other SPROC invoke it?

Thanks in advance.

Ricky.

You can write C#, VB.NET methods that can be used from inside SQL Server to call .NET libraries.

Niels
|||Yes, you can write a stored proc in clr (C# or VB.NET) that can call methods in the .NET Framework.
Yes.

http://msdn2.microsoft.com/en-us/library/ms131052.aspx|||

If the SPORC written with C# needs to call another C# method that is within a thrid-party component, is it feasible implement in the SQL server 2005?

Thanks,

Ricky.

|||Yes, but you have to deploy that third party component to the database as weel (i.e together with your original .NET assembly(ies)).

Niels
|||

Hi, nielsb.

I create a database project trying to add reference.

However, I cannot add .dll except for built-in .net library.

How do I deploy a third-party .dll onto sql server 2005? Please give me example if possible.

Thanks a million.

Ricky.

|||Deploy your third party dll manually to SQL Server, by using CREATE ASSEMBLY syntax. Read more about CREATE ASSEMBLY in SQL Server Books OnLine. By deploying it manually, you can then reference it from your database project.

Niels
|||

Thanks too much.

nielsb.

By the way, someone told me that previously (before .net era), he could wrote extended sproc with C and umlinitedly access the library outside SQL server. Why cannot we do as him currently? Security consideration?

Ricky.

|||

Ricky Wang wrote:

By the way, someone told me that previously (before .net era), he could wrote extended sproc with C and umlinitedly access the library outside SQL server. Why cannot we do as him currently? Security consideration?

Extebded stored proc's are still supported in SQL 2005, but are being deprecated. Main reason for this is security and reliability issues. The extended proc's are deprecated in favor of .NET methods. You can almost do anything that you are doing in and XP in a .NET method.

Niels
|||

Thanks for explanation.

Ricky.

No comments:

Post a Comment