I have a query Excel in each of my rows, about 2000. When I copy paste all queries into SQL Server roughly 100 rows are showing a error. Might not even be an error but the query will paste into SQL Server with double quotes in front of entire query.
I have error checking in place so it has something to do with the data in my Excel sheet. My query pasted in SQL Server for instance:
"insert into
I cannot paste the entire query or any data, sorry.
Thank you for looking at this
If you need to use the double quote inside the string, you can use the backslash character. Notice how the backslash in the second line is used to escape the double quote characters. And the single quote can be used without a backslash.
Double quotes generally aren't used in SQL, but that can vary from database to database. Stick to using single quotes.
This occurs when a line has an embedded carriage return, it may happen in other situations as well. I just do a find/replace for double quotes in the resulting query, but you could also first paste it into Word then copy from there and it will paste without the quotes.
Alternatively, if it's just from embedded returns you could wrap your formula in a pair of SUBSTITUTE()
functions to remove CHAR(13)
and CHAR(10)
if formula was in A1
:
=SUBSTITUTE(SUBSTITUTE(A1,CHAR(13),""),CHAR(10),"")
Actually a lot easier then all of the posts here, in another column do the following formula:
=CLEAN(MyCell)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With