1

I am trying to find the syntax for inserting the results from an UNPIVOT statement into an existing table in the database?

Grace
  • 2,548
  • 5
  • 26
  • 23

1 Answers1

2

simplest answer which works for any SELECT including UNPIVOT would be...

INSERT INTO MyTable
SELECT statement

However, this does require that your destination tables columns match your SELECT statement columns.

Although you can get around this limitation with...

INSERT INTO MyTable (column1, column2....)
SELECT statement
Rich Andrews
  • 4,168
  • 3
  • 35
  • 48