It doesn’t even detect the first format and just runs “USE sql_invoicing;”
What’s going on?
Syntax looks okay. I would suggest you post only the code of the stored procedure that isn’t working, and try it in a file by itself. This is because it is hard to tell if this error is actually from the code you think it is from or maybe from somewhere else (it looks like you have thousand+ lines in the file, and even the same stored procedure in there twice - too many opportunities for errors when you have so much code running at once).