jump to navigation

SQL COPY PASTE form one table to another and BIT values turn into NULL 5 agosto, 2015

Posted by haegeth in SQL.
Tags: , , , ,
1 comment so far

Today I wanted to share this because it has been a real pain to find a solution.

I had to copy some values from one table to another, both with same schema, same columns same data types, it was a matter of copying data from PRODUCTION to TEST environments and it turned out that all values of BIT type were converted automatically to NULL.

Even a COPY-PASTE directly from one table to the other I got the same behavior.

Well, for some reason, to paste BIT values into a table it has to be in a TRUE-FALSE format, so if in the source table they are 1’s and 0’s it won’t understand them.

So, what I did was to paste all data in EXCEL, format the BIT cells as boolean so the 1’s and 0’s were converted to TRUE and FALSE, copied all the information and pasted them to the target table.

Voila, problem solved.

SQL Copy Paste de una tabla a otra y los valores de tipo BIT se convierten en NULL 5 agosto, 2015

Posted by haegeth in SQL.
Tags: , , , , ,
add a comment

Hoy quiero compartir esto porque me ha causado un gran dolo de cabeza solucionarlo.

Tenía que copiar los valores de una tabla a otra, identicas, mismo esquema, solo era pasar unos datos de PRODUCCION a TEST y resulta que todos los valores de tipo BIT se convertian automaticamente en NULL.

Incluso si hacia COPY-PASTE directamente de una tabla a otra pasaba esto.

Bueno, por alguna razon para pegar datos de tipo BIT tienen que estar definidos como TRUE y FALSE, si en la tabla de origen estan como 1 y 0 no los va entender.

Entonces lo que hice fue copiar los datos a Excel, darle formato a los campos de tipo BIT para que convirtiera los 1’s y 0’s en TRUE y FALSE, despues los copié y despues los pegué en la tabla destino.

Listo, problema solucionado.