Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
madamvegas
Starting Member
3 Posts |
Posted - 2012-05-10 : 10:23:44
|
| I have an Access db that an employee created that had some VBA code in it that I need to convert to SQL. Not familiar with VBA and new to SQL. What the code does is replaces ASCII charcters with spaces.Here is a snippet of the code.Function Dead(TextIN As String, Optional NonPrints As Boolean) As StringDim Str As String Str = Trim(TextIN) If NonPrints Then Dim x As Long ' remove all non-printable characters While InStr(Str, vbCrLf) > 0 Str = Replace(Str, vbCrLf, " ") Wend For x = 126 To 160 While InStr(Str, Chr(x)) > 0 Str = Replace(Str, Chr(x), "") Wend Next x End If While InStr(Str, String(2, " ")) > 0 Str = Replace(Str, String(2, " "), " ") WendDead = StrEnd FunctionSo not sure how to look for ASCII characters in SQL and how to do the loop.Any help to get me in the right direction would be appreciated.Theresa Burk |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2012-05-10 : 11:26:10
|
Assuming you want to learn to fish vs. have the fish handed to you:I suggest you - browse this site's Script Library forum. - get used to referring to Books Online ie: built in string functionsyou can start with this:select ascii('t'), char(116)declare @i int ,@s varchar(50) select @i = 126 ,@s = 'madam' + char(128) + 'vegas'select @swhile @i < 161begin set @s = replace(@s, char(@i), ' ') set @i = @i+1endselect @sOUTPUT: ----------- ----116 t--------------------------------------------------madam€vegas--------------------------------------------------madam vegasBe One with the OptimizerTG |
 |
|
|
|
|
|
|
|