IF exists (select * from dbo.sysObjects where id = Object_id (n '[dbo]) and xtype in (n'fn', n'if ", n')) DROP FUNCTION [DBO] [f_replace] Go
/ * - illegal character replacement function
Detained in the string, the characters of less than 32 retain Tab Char (9) Wrap Char (10) Enter Char (13) If the above characters are not required, the comment in the function is deleted - Zou Jian 2004.09 (Reference Please keep this information)--*/
/ * - Call example
- Call the function to replace the sample declare @s varchar (10) set @ s = 'a' 'b' char (11) 'c'
Select dbo.f_replace (@s) - * / create function f_replace (@str varchar (8000)) Returns varchar (8000) asbeginselect @ str = Replace (@ Str, A, '') from (SELECT A = n ') Union All Select N '' Union All Select N''Union All Select N '' Union All Select N'''Union All Select N '' Union All Select N''Union All Select N '--Union All Select N' ' - Tab Char (9) - Union All Select N '-' - 'Walking Char (10) Union All Select N''Union All Select N' '- Union All Select N' - '-' Enter Char (13) Union All Select N '' Union All Select N''Union All Select N '' Union All Select N'' ELE SELECT N '' Union All Select N''Union All Select N '' Union All Select N '' Union All Select N '' Union All Select N''Union All Select N '' Union All Select N''Union All SELECT N '