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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Using a VB Script fuction when doing an update

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-22 : 09:04:27
Anthony writes "Hi I want to do an update of my entire SQL Database, but run some of the data thru a custom VB Script Function. For example:

Update my_table Set fname = PCase(fname), lname = PCase(lname)

PCase is a function to set the proper case of the string.


Private Function PCase(byVal string)
Dim Tmp, Word, Tmp1, Tmp2, firstCt, a, sentence, c, i
If IsNull(string) Then
PCase = Null
Exit Function
Else
string = CStr( string )
End If
a = Split( string, vbCrLf )
c = UBound(a)
i = 0
For each sentence in a
Tmp = Trim( sentence )
Tmp = split( sentence, " " )
For Each Word In Tmp
Word = Trim( Word )
Tmp1 = UCase( Left( Word, 1 ) )
Tmp2 = LCase( Mid( Word, 2 ) )
PCase = PCase & Tmp1 & tmp2 & " "
Next
PCase = Left( PCase, Len(PCase) - 1 )
If i = c then
Else
PCase = PCase & vbCrLf
End If
i = i + 1
Next
End Function




How would I go about doing this?

Thanks,
Anthony"
   

- Advertisement -