begin
declare @popedomstring varchar(5000);
declare @i int;
set @i = 1;
select @popedomstring = PopedomString from PUB_EmployeePopedomConnection where EmployeeCode = '148527';
if len(@popedomstring) > 0
select 'u are right';
begin
while @i <= len(@popedomstring)
begin
if left(@popedomstring,@i)<>'1'
set @popedomstring = stuff(@popedomstring,@i,1,'1');
set @i = @i + 1;
if len(@popedomstring)>1
update PUB_EmployeePopedomConnection set PopedomString = @popedomstring where EmployeeCode = '148527';
else
select @popedomstring;
end
end
end
declare @a varchar(100)
set @a='132,125,12,235,1244,234,23'
set @a=replace(','+@a+',',',23,',',')
set @a=right(left(@a,len(@a)-1),len(@a)-2)
print @a
declare @a nvarchar(500)
declare @repcha nvarchar(10)
set @repcha = '12'
set @a='132,125,12,235,1244,234,23'
if (substring(@a,len(@a),1)<>',') set @a=@a+','
set @a =replace(@a,@repcha+',','')
if (substring(@a,len(@a),1)=',') set @a=substring(@a,0,len(@a))
print @a