Concatenate, remove space, and convert into multiple records

Database

Concatenate, remove space, and convert into multiple records

Compare table with spaces in between data, with table without spaces

Example:-

Table A has three fields: ID, Cd_1, and Cd_2

Fields: Cd_1 or Cd_2 can have spaces between the codes. Below example has space between X and Y in Cd_1

ID  Cd_1  Cd_2

1    X  Y      Z 

Table B has two fields:  ID, Code

Table B is supposed to populate codes (non-spaces) from Cd_1, and Cd_2 from Table A

Example:

ID Cd

1  X

1  Y

1  Z

I need to Select write a query in table A, so it will match output in table B