Delete after nth occurence of string in each line

Hello,
Environment:
I am under Ubuntu 18.04 bionic. I have an sql file consisting of 10K lines.
Objective:
What I am trying to attain is to remove everything coming after 2nd tab in each line. While searching for the answer, I found two answers and both gave expected result just for the first line of mysql file.

Works just first line

sed -r 'H;1h;$!d;x; s/(([^\t]*\t){2}).*/\1/' mysql

When I run below, it gives thousands of errors.

while read -r line
do
sed -r 'H;1h;$!d;x; s/(([^\t]*\t){2}).*/\1/' "$line"
done < mysql

Also this one:

while read -r line
do
awk -v RS='\t' -v ORS='\t' 'NR==1{print} NR==2{print; printf"\n";exit}' $line
done < mysql

I'd appreciate your help
Thanks
Boris

What happens if you just try:

sed -r 's/(([^\t]*\t){2}).*/\1/' mysql
1 Like

Hello Don,
Thank you so much... As expected!

Boris