Control Freak
Control Freak

Reputation: 13243

Using RegExp in SQL Server Stored Procedure

This is the code in VB Script, how would it be done if i was to build a function called dbo.FileNameEncode(str) in SQL Server ?

Function FileNameEncode(ByVal strFileName)     
    Dim oReg     
    strFileName = LTrim(Rtrim(strFileName))
    Set oReg = New RegExp     
    oReg.IgnoreCase = True     
    oReg.Global = True     
    oReg.Pattern = "[^a-z\d\s.]+"     
    FileNameEncode = Replace(oReg.Replace(strFileName, ""), " ", "_")     
    Set oReg = Nothing 
End Function 

Upvotes: 2

Views: 1344

Answers (1)

Related Questions