SQLSERVER 插入 INSERT INTO 特殊字符过滤

/// <summary>
/// 特殊字符过滤
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
private static string String2Json(string s)
{
return s.Replace("'", "'+char(39)+'").Replace("&", "'+char(38)+'");
}

  

其中 char(39)代表英文单引号'  char(38) 代表&  还有一些其它字符需要过滤的话在后面拼接上就好,下面是查询的结果

       

select char(39)
select char(38)

 


posted @ 2019-06-11 10:26  桎梏110  阅读(1745)  评论(0编辑  收藏  举报
Live2D