I have a stored procedure that returns rows:
CREATE PROCEDURE MyProc
AS
BEGIN
SELECT * FROM MyTable
END
My actual procedure is a little more complicated, which is why a stored procedure is necessary.
Is it possible to select the output by calling this procedure?
Something like:
SELECT * FROM (EXEC MyProc) AS TEMP
I need to use SELECT TOP X
, ROW_NUMBER
, and an additional WHERE
clause to page my data, and I don't really want to pass these values as parameters.
Ctrl+T
to output the result as text, and copy the first column line and remove extra whitespaces from there and you'll get your column names easily. To go back to Grid output pressCtrl+D
INSERT
theEXEC
iff your sproc isn't too complicated, 3. cheat and useOPENQUERY
. But each answer is repeated an amazing number of times, many with a downright startling number of upvotes. You've been warned. 🙈