Given the following table layout and data rows:
SELECT [Id]
,[EmailAddress]
,[PhoneNumber1]
,[PhoneNumber2]
,[FaxNumber]
FROM [Database].[dbo].[Table1]
1 NULL 800-222-2222 800-333-3333 800-444-4444
2 e@email.com 800-555-5555 800-777-7777 800-888-8888
I'm looking to insert a new row for each column that is not null into the following table layout:
SELECT [Id]
,[FkId]
,[Value]
FROM [Database].[dbo].[Table2]
Here's an example of what I believe the desired output to be.
1 1 800-222-2222
2 1 800-333-3333
3 1 800-444-4444
4 2 e@email.com
5 2 800-555-5555
6 2 800-777-7777
7 2 800-888-8888
Big picture, I'm looking to repeat this INSERT
for every row in Table1
. Figuring out how to do this for at a minimum of one row would be a good starting point.