Posted on: 8/16/2013 3:56:09 PM | Views : 840

 
Hi everyone,
active (bit) <=========== MS SQL 2012 database tableA
acitve (varchar(10) <========== MS SQL 2012 database tableB
And tableB.active contains "yes", "no", "no", "yes", "yes", "yes", "no", ... etc.
Now I want to insert 1 into tableA.active if tableB.active = 'yes' And insert 0 into tableA.active if tableB.active = 'no'
My SQL code is something below. And I am sure the my SQL code does not work:
INSERT into tableA(active) SELECT '1' from tableB where tableB.active = 'yes' SELECT '0' from tableB where tableB.active = 'no'
Please modify my SQL code so that it will work.
Thanks,
May
 
...

Go to the complete details ...