Executing a Stored Procedure that returns a result set in MS SQL Server

Added by Eduardo Bezerra 13 days ago


I'm trying to execute a Stored Procedure in MS SQL Server, that returns a result set, but I can't figure what is the correct syntax.

I have the following Dbo class:

struct Auth {
std::string userName;
std::string password;

template<class Action>
void persist(Action& a) {
dbo::field(a, userName , "UserName");
dbo::field(a, password , "Password");

In the Database a have a simple Stored Procedure like:

create procedure sp_ViewAuth as
select UserName, Password from [Authorization] D

The syntax I'm trying is;
collection< ptr<Auth> > recs = session.query< ptr<Auth> >("exec dbo.sp_ViewAuth");

But I got the error:
Error parsing SQL query: "exec dbo.sp_ViewAuth"

What would be the correct syntax to execute a Stored Procedure that returns a result set?