I need to replace some special characters in a name field. Im pretty sure my syntax is correct because it works when I run it by itself. However when I run the whole procedure it doesnt update. the code is below.. this is part of a larger proc that is called as part of 10 steps. One .sql file is called and that one calls this on. After loading the data I still see the special characters in the field as if it ignored my replace statement. If I run the whole batch, verify the characters exist and then just run these statements, the characters are removed. Is there a certain commit or something I need to do to get these statements to work when run as a batch?
-- cleanup of raw1 data
declare @specchar varchar(10)
set @specchar = 'á'
begin
set @sql ='update raw1 set name=replace(name,''$specchar$'','''')'
set @sql = replace(@sql,'$specchar$', @specchar)
exec ( @sql )
end
begin
set @sql ='update raw1 set Affiliate=replace(Affiliate,''$specchar$'','''')'
set @sql = replace(@sql,'$specchar$', @specchar)
exec ( @sql )
end
begin
set @sql ='update raw1 set Address=replace(Address,''$specchar$'','''')'
set @sql = replace(@sql,'$specchar$', @specchar)
exec ( @sql )
end
begin
set @sql ='update raw1 set ScopeofDisqualification=replace(ScopeofDisqualification,''$specchar$'','''')'
set @sql = replace(@sql,'$specchar$', @specchar)
exec ( @sql )
end
begin
set @sql ='update raw1 set Office=replace(Office,''$specchar$'','''')'
set @sql = replace(@sql,'$specchar$', @specchar)
exec ( @sql )
end
/*
truncate table ident
truncate table aka
truncate table crimes
*/
...The inserts from the raw table into the 3 data tables is performed here -- works fine
-- cleanup of raw1 data
declare @specchar varchar(10)
set @specchar = 'á'
begin
set @sql ='update raw1 set name=replace(name,''$specchar$'','''')'
set @sql = replace(@sql,'$specchar$', @specchar)
exec ( @sql )
end
begin
set @sql ='update raw1 set Affiliate=replace(Affiliate,''$specchar$'','''')'
set @sql = replace(@sql,'$specchar$', @specchar)
exec ( @sql )
end
begin
set @sql ='update raw1 set Address=replace(Address,''$specchar$'','''')'
set @sql = replace(@sql,'$specchar$', @specchar)
exec ( @sql )
end
begin
set @sql ='update raw1 set ScopeofDisqualification=replace(ScopeofDisqualification,''$specchar$'','''')'
set @sql = replace(@sql,'$specchar$', @specchar)
exec ( @sql )
end
begin
set @sql ='update raw1 set Office=replace(Office,''$specchar$'','''')'
set @sql = replace(@sql,'$specchar$', @specchar)
exec ( @sql )
end
/*
truncate table ident
truncate table aka
truncate table crimes
*/
...The inserts from the raw table into the 3 data tables is performed here -- works fine