I have a DMV query that generates database/cube metadata.
DMV_Query = 'SELECT [SESSION_ID],[SESSION_SPID] FROM $SYSTEM.DISCOVER_SESSIONS';
I want to take these resulted columns’ data
[SESSION_ID],[SESSION_SPID] and have an insert query automatically recognize matching columns in an empty table, let say called “DMV_Table”.
I essentially want to accomplish something like this:
'INSERT INTO DMV_Table (SESSION_ID, SESSION_SPID) VALUES ($DMV_QUERY)'
in which the values are automatically inserted into the matched column name
How can i do that?