Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Use output parameter?

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2007-04-05 : 08:43:19
Hello,

I have a simple procedure which for a given ID returns only one record.
I have this made in two different ways:
1. Use Output parameters for each column in table.
In my .NET code I execute a non query.
2. Use select without individual parameters
In my .NET code I execute a dataset

Which should I use?

In case of using (2):
I have 2 procedures: GetAllDocuments and GetDocument

The difference is that GetDocument uses a DocumentId to select only one document (record). Should I use only one procedure and test if DocumentId is null or use the two procedures.

Just would like a second opinion.
I have this working in different ways.

Thanks,
Miguel

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-05 : 08:55:27
My strategy is:

1. Use output parameter when no. of output values limited to 1 or 2
2. Use regular SELECT statement when I need a resultset which has considerable no. of values
3. Use single SP with a default parameter when most of the Proc logic is same

General rule of thumb is prefer the approach where you can maintain the code easily and still achieve what you want efficiently.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -