Scripts to remove Line Feeds or Carriage Returns in the IN_Part Table

Description of Issue: 

If Part codes, Descriptions, or other text fields contain line feeds or carriage returns in the field, it can cause problems in the application. 

Resolution: 

The scripts below can be used to remove these from the fields in the IN_Part table.  

--- Backup Table before making changes. ---  

select * INTO IN_PART_backup12345 from IN_Part   

UPDATE IN_Part  
set  
Part_Code = REPLACE(Part_Code, char(10), ''), 
Description = REPLACE(Description, char(10), '') , 
Detail = REPLACE(Detail, char(10), ''), 
Purchase_Description = REPLACE(Purchase_Description, char(10), ''), 
Vendor_Part = REPLACE(Vendor_Part, char(10), ''), 
Service_Description = REPLACE(Service_Description, char(10), ''), 
Sales_Description = REPLACE(Sales_Description, char(10), ''), 
Manufacturer_Part_Code = REPLACE(Manufacturer_Part_Code, char(10), '') 
--Select * from IN_Part 
Where Part_Code like '%'+char(10)+'%' 
or Description like '%'+char(10)+'%' 
or Detail like '%'+char(10)+'%' 
or Purchase_Description like '%'+char(10)+'%' 
or Vendor_Part like '%'+char(10)+'%' 
or Service_Description like '%'+char(10)+'%' 
or Sales_Description like '%'+char(10)+'%' 
or Manufacturer_Part_Code like '%'+char(10)+'%'   

UPDATE IN_Part  
set  
Part_Code = REPLACE(Part_Code, char(13), ''), 
Description = REPLACE(Description, char(13), ''), 
Detail = REPLACE(Detail, char(13), ''), 
Purchase_Description = REPLACE(Purchase_Description, char(13), ''), 
Vendor_Part = REPLACE(Vendor_Part, char(13), ''), 
Service_Description = REPLACE(Service_Description, char(13), ''), 
Sales_Description = REPLACE(Sales_Description, char(13), ''), 
Manufacturer_Part_Code = REPLACE(Manufacturer_Part_Code, char(13), '') 
--Select * from IN_Part-- 
where Part_Code like '%'+char(13)+'%' 
or Description like '%'+char(13)+'%' 
or Detail like '%'+char(13)+'%' 
or Purchase_Description like '%'+char(13)+'%' 
or Vendor_Part like '%'+char(13)+'%' 
or Service_Description like '%'+char(13)+'%' 
or Sales_Description like '%'+char(13)+'%' 
or Manufacturer_Part_Code like '%'+char(13)+'%'  
Was this article helpful?
Thank you for your feedback!
User Icon

Thank you! Your comment has been submitted for approval.