0

I'm new to SQL Server programming, so this may or may not be a stupid question.

So, first I do not know what my input table is (my task is supposed to work with ANY table).

Second, I get the column names using sp_help and then I select only that column into another table. Now I need the rows from COLUMN_NAME to be the names of god knows how many columns into some new table.

I tried something using PIVOT, but I can't seem to make it work.

4

1 回答 1

0

听起来您想访问元数据表。这样的事情可能会让你朝着正确的方向前进:

insert into column_name(name)
    select column_name
    from information_schema.columns
    where table_name = XXX       <----- YOUR TABLE GOES HERE
于 2013-06-25T02:32:29.940 回答