Guest User

Untitled

a guest
Aug 15th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. Creating a UserDefined CLR function in .Net
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using Microsoft.SqlServer.Server;
  7. using System.Data.SqlTypes;
  8. using Microsoft.SqlServer.Types;
  9.  
  10. namespace ClassLibrary1
  11. {
  12. public partial class Class1
  13. {
  14. [Microsoft.SqlServer.Server.SqlFunction]
  15. public static SqlString GetPassword(SqlString Value)
  16. {
  17. return Value;
  18. }
  19. }
  20. }
  21.  
  22. CREATE ASSEMBLY ASSEM
  23. authorization dbo
  24. FROM 'E:NBM Sitestvt.stage.asentechdev1.comClassLibrary1.dll' WITH PERMISSION_SET = SAFE;
  25.  
  26. CREATE FUNCTION SampleFunc
  27. (
  28. @value nvarchar(max)
  29. )
  30. RETURNS nvarchar(max) with execute as caller
  31. AS
  32. External Name ASSEM.Class1.GetPassword
  33. GO
  34.  
  35. Could not find Type 'Class1' in assembly 'ClassLibrary1'.
  36.  
  37. CREATE FUNCTION SampleFunc
  38. (
  39. @value nvarchar(max)
  40. )
  41. RETURNS nvarchar(max) with execute as caller
  42. AS
  43. External Name [ASSEM].[ClassLibrary1.Class1].[GetPassword]
  44. GO
Add Comment
Please, Sign In to add comment