简体   繁体   中英

Stored Proc : Use Return or Select at end?

If I'm creating a C# wrapper for a stored proc, and that sp only returns/selects (not sure) 1 value, should I use return or select at the end of that sp?

This is for t-sql.

Return can only return (no pun intended) an integer and you can only return 1 value

An output parameter can return all datatypes and you can have multiple output parameters per proc

A select statement can return a resultset

It all depends what you want to accomplish in your calling code, I myself prefer output parameters

You have a couple choices. You can use an OUTPUT parameter to your stored procedure, a Select statement, or a return value. If I had to guess, I would say an OUTPUT parameter would be the most commonly used given your situation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM