删除SQL Server 2005中的特殊字符

时间:2012-02-09 13:01:38

标签: sql-server-2005 special-characters

我在Dummy表中找到了一个错误插入值"123"的列。

如何从字段中的值中删除双引号,而在该字段中包含123.

帮帮我

感谢您的期待

3 个答案:

答案 0 :(得分:3)

描述

您可以使用T-SQL的replace方法

  

将所有出现的指定字符串值替换为另一个字符串值。

示例

UPDATE Dummy set myColumn = replace(myColumn,'"','')

更多信息

答案 1 :(得分:2)

update dummy set your_field = replace(your_field, '"', '')

答案 2 :(得分:2)

USE [YourDataBase]
GO
/****** Object:  UserDefinedFunction [Accounts].[fn_CurrentFeeorArrears]    Script Date: 02/18/2014 12:54:15 ******/
/*****Developed By rameez****/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [FN_REMOVE_SPECIAL_CHARACTER] 
(  
 @INPUT_STRING varchar(max))
RETURNS VARCHAR(max)
AS 
BEGIN

--declare @testString varchar(max),
DECLARE @NEWSTRING VARCHAR(max) 
-- set @teststring = '$rameez$ali$'
 SET @NEWSTRING = @INPUT_STRING ; 
With SPECIAL_CHARACTER as
(
--SELECT '>' as item
--UNION ALL 
--SELECT '<' as item
--UNION ALL 
--SELECT '(' as item
--UNION ALL 
--SELECT ')' as item
--UNION ALL 
--SELECT '!' as item
--UNION ALL 
--SELECT '?' as item
--UNION ALL 
--SELECT '@' as item
--UNION ALL 
--SELECT '*' as item
--UNION ALL 
--SELECT '%' as item
--UNION ALL 
SELECT '$' as item
 )
SELECT @NEWSTRING = Replace(@NEWSTRING, ITEM, '') FROM SPECIAL_CHARACTER  
return @NEWSTRING 
END
select dbo.[FN_REMOVE_SPECIAL_CHARACTER] ('r$@ameez')