May 29, 2011 at 8:09 pm
Hi I have created the below UDF from SQl CLR database Project from Visiual Studio 2010
and after diploying the UDF it works fine on the sql test Server
Since my SQl Production server is a shared hosting server it does not support the .Net Framerwork CLR, It is disabled on the sql 2008 database
Can some one help me to convert this function into a SQL standalone UDF
Public Shared Function ChecksumMTS(ByVal MerchantxnStem As String) As String
Const ReplaceChars As String = ("abcdef")
Const ReplaceWith As String = ("JKLMPR")
Dim sha_1 As New SHA1CryptoServiceProvider()
Dim i As Long
Dim a As Byte() = Encoding.UTF8.GetBytes(MerchantxnStem)
Dim t As String = Convert.ToBase64String(sha_1.ComputeHash(a))
t = Mid(t, 2, 2)
i = InStr(ReplaceChars, (Left(t, 1)))
If i Then
Mid(t, 1, 1) = Mid(ReplaceWith, i, 1)
End If
i = InStr(ReplaceChars, (Right(t, 1)))
If i Then
Mid(t, 2, 1) = Mid(ReplaceWith, i, 1)
End If
ChecksumMTS = t
End Function
Thanks
May 31, 2011 at 8:37 am
Duplicate post. Please direct replies here
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply