Syntax
REPLACE ('string _ e-xpression1', 'string _ e-xpression2', 'string _ e-xpression3 ')
Parameter description
'String _ e-xpression1'
String expression to be searched. String_e-xpression1 can be character data or binary data.
'String _ e-xpression2'
String expression to be searched. String_e-xpression2 can be character data or binary data.
'String _ e-xpression3'
String expression used for replacement. String_e-xpression3 can be character data or binary data.
The format is as follows:
Update table name SET column to be replaced = REPLACE (the column to be replaced, the character to be replaced, and the character to be replaced)
Example SQL statement:
Update tableName SET columeName = REPLACE (columeName, 'A', 'B ')
However, it is worth noting that SQL Server has a replace function that can be used directly. The replace function of the Access database can only be used in the Access environment and cannot be used in Jet SQL, so it is useless to ASP, when you call this function in ASP, an error is displayed: The 'replace 'function in the expression is not defined. You can write a function in Asp to implement this function.
Example function:
Copy codeThe Code is as follows:
Function replace (title)
{
Replace (title, 'aaa', 'bbbbbb ')
Return (title)
}
Bbb = replace (title)
Update... set title = '"& bbb &"'
Reference code for ASP + access batch replacement of specified characters:
Copy codeThe Code is as follows:
<%
Set Conn = Server. CreateObject ("ADODB. Connection ")
Conn. Open "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" & Server. MapPath ("database name. mdb ")
Set rs = Server. Createobject ("ADODB. Recordset ")
SQL = "Select * from [Table name]"
Rs. open SQL, conn, 1, 3
While not rs. eof
Rs ("field name") = replace (rs ("field name"), "replaced character", "replaced character ")
Rs. update
Rs. movenext
Wend
Rs. close
Set rs = nothing
Conn. close
Set conn = nothing
%>