In SQL Server, how can I query the system tables to return all the column names of a stored procedure? For a view, I know I can use sp_columns or sys.columns. But when I use those against my stored procedure, it returned 0 rows.
I have tried the following:
EXEC sp_columns MyStoredProc;
and:
SELECT *
FROM sys.columns
WHERE [object_id] = OBJECT_ID('MyStoredProc');
Both returned nothing.
Thanks in advance
If you are asking for SQL 2012 or later, you can use
exec sp_describe_first_result_set N'your-stored-procedure-name'
Note: This will return the first result set returned by your stored procedure.
MSDN
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With