fcobuzzi
asked on
If or Case Statement
Hi,
I'm trying to write a script that will do the following:
It will verfiy what code is in Table A and then it will write a pre determined number into Table B.
Example:
Table A Codes
HRT
HRA
OA
So if the code in Table A is HRT it will write 8 into Table B.
I don't know if I should use If or Case statement.
TIA,
Frank
I'm trying to write a script that will do the following:
It will verfiy what code is in Table A and then it will write a pre determined number into Table B.
Example:
Table A Codes
HRT
HRA
OA
So if the code in Table A is HRT it will write 8 into Table B.
I don't know if I should use If or Case statement.
TIA,
Frank
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you just want a record inserted to Table B if there's a HRT in Table A, this should work:
INSERT INTO Table B
SELECT 8
WHERE EXISTS (SELECT 'X' FROM TableA WHERE Code = 'HRT')