First question:
UPDATE exp_channel_data SET text_column = REPLACE(text_column, '\r\n', '<br />')
If it does not replace anything, use '\n' instead of '\r\n' .
Second question:
You cannot do this with a SQL query, you need to extract this data in a PHP script or anything else that you like and perform a regular expression replacement (example for PHP):
$new_str = preg_replace('#<(p|span)[^>]+>#', '<$1>', $old_string);
Crack source share