Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

how to write vb.net code into sqlserver

$
0
0

Hi All,

I have a table named orders with 10 colums ,in that i have one coulmn contact_id which contains 15 digit number,now i want to make it as 18 digit number by using below vb.net code in sqlserver.Can some one help me on this.

Below is the vb.net code which needs to e converted to sql server query:

Function Id_18(InID As String) As String
Dim InChars As String, InI As Integer, InUpper As String
Dim InCnt As Integer
 
    If Len(InID) = 18 Then
        Id_18 = InID
        Exit Function
    End If
   
    InChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"
    InUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
   
    InCnt = 0
    For InI = 15 To 1 Step -1
        InCnt = 2 * InCnt + Sgn(InStr(1, InUpper, Mid(InID, InI, 1), vbBinaryCompare))
        If InI Mod 5 = 1 Then
            Id_18 = Mid(InChars, InCnt + 1, 1) + Id_18
            InCnt = 0
        End If
    Next InI
    Id_18 = InID + Id_18
   
End Function
 

Regards,

Sudha


sudha


Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>