Skip to content
Advertisement

Declare table variable with columns as mush as row in second table

I have a table with id in database. I want to declare table variable with columns as much as id count in the id table(now its 16, but in future it will be more).

enter image description here

The columns name must be the id name.

enter image description here

I tried to use table_cursor, and dynamic query with creating table variable. And its worked, but in the future its called a lot of troubles. Does it possible to create table variable without dynamic query?

Advertisement

Answer

Try this

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement