Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you do a select on the results of a stored procedure in T-SQL

select * from (EXEC sp_SomeStoredProc)

If you can't do this then what is stopping it from being added to the SQL standard or T-SQL?

like image 563
Jonathan Parker Avatar asked Apr 08 '09 07:04

Jonathan Parker


1 Answers

You can't do this, however you can do it as an insert. e.g.

insert mytable
exec myStoredProcedure

Also, never name your stored procedures sp_xxxx. This is because SQL will always search in the system stored procedure area due to the sp_ before looking in the user stored procedures, leading to a small loss in performance that could add it to be fairly significant on a process that is run frequently.

like image 166
cjk Avatar answered Sep 30 '22 04:09

cjk