Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. 1 | This is an example of ' single, " double, and \ backslash (in the messed up records)
  2. 2 | This example is how it gets stored now backslash ' single " double
  3.  
  4. 1 | This is an example of ' single, " double, and backslash
  5.  
  6. 2 | This example is how it gets stored now backslash ' single " double
  7.  
  8. 1 | This is an example of ' single, " double, and backslash (how data should be)
  9.  
  10. DROP TABLE IF EXISTS tmpTable;
  11. CREATE TEMPORARY TABLE IF NOT EXISTS tmpTable ( BadText VARCHAR(100));
  12.  
  13. INSERT INTO tmpTable
  14. SELECT 'This is an example of \' single, \"double, and \\ backslash';
  15.  
  16. select BadText from tmpTable;
  17.  
  18. update tmpTable
  19. set BadText = replace(replace(replace(BadText,'\'','''),'\"','"'),'\\','\');
  20.  
  21. select BadText as GoodText from tmpTable;
  22.  
  23. SELECT REGEX_REPLACE(your_column, '.*backslash{2,}.*', 'backslash') FROM table
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement