I'm converting some data in SQL Server:
INSERT INTO MYTABLE (AllowEdit) (Select PreventEdit from SOURCETABLE) so I need to inverse the bit value from source table. I expected NOT to work, as this is how I would do it in code, but it doesn't. The most elegant way I can think of is:
INSERT INTO MYTABLE (AllowEdit) (Select ABS(PreventEdit -1) from SOURCETABLE) Is there a more standard way to do it?
I did not test this myself, but you should be able to use the bitwise negation operator, ~ on a bit:
INSERT INTO MYTABLE (AllowEdit) (SELECT ~PreventEdit FROM SourceTable)
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