Have you ever run a stored procedure, only to be overwhelmed at the number of columns returned? Maybe you only needed one or two columns, but it presented you with way too many columns for your needs on this particular occasion.
Fortunately, there’s a little trick you can use to retrieve selected columns from a stored procedure. This enables you to get just the columns you need.
And the best part is, it doesn’t involve having to create temporary tables and shuffling the data around.
All you need to do is pass your stored procedure to the OPENROWSET()
function.
The same concept can be applied to the OPENQUERY()
function.