こんにちは、テーブルから特殊文字を削除したいのですが、ストアド プロシージャで試しています。、、、などの特定の特殊文字だけを削除したい?
のですが'
、日付やその他の記号があります。"
#
$
CREATE PROCEDURE [dbo].[ScrubData]
(
@TableName Varchar(100)
)
AS
BEGIN
DECLARE @SQL1 nVARCHAR(MAX)
DECLARE @SQL2 nVARCHAR(MAX)
DECLARE @SQL3 nVARCHAR(MAX)
DECLARE @SQL4 nVARCHAR(MAX)
select @SQL1 =
'update ' + TABLE_NAME +
' set ' + column_name + ' = replace ('+ column_name +', '','','''')
where ' + column_name + ' like ''%,%'''
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = @TableName and COLUMN_NAME like '%load'
select @sql2 =
'update ' + TABLE_NAME +
' set ' + column_name + ' = replace ('+ column_name +', '''''','''')
where ' + column_name + ' like ''%''%'''
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = @TableName and COLUMN_NAME like '%load'
select @SQL3 =
'update ' + TABLE_NAME +
' set ' + column_name + ' = replace ('+ column_name +', ''"'','''')
where ' + column_name + ' like ''%"%'''
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = @TableName and COLUMN_NAME like '%load'
select @SQL4 =
'update ' + TABLE_NAME +
' set ' + column_name + ' = replace ('+ column_name +', ''#'','''')
where ' + column_name + ' like ''%#%'''
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = @TableName and COLUMN_NAME like '%load'
print(@sql1)
print(@sql2)
print(@sql3)
print(@sql4)
end