473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Stored Procedure Best Practice

I have a situation in which I need two stored procedures that do basically
the same thing,
but takes in a different parameter value and return less of the same data. I
wonder is it best to
do two different stored procedures or just one to accomplish my goal?

The first sp take in the @emailaddress parameter value and selects the
following values from two different table:
Username, Password, FirstName, LastName

for completeness here the full second sp....

CREATE PROCEDURE GetStudentDetail
@AccountID INT
AS
SELECT A.Username, A.Password, A.SecretQuestion, A.SecretAnswer,
A.RoleID, A.Active, S.FirstName, S.LastName,
S.BirthMonth, S.BirthDay, S.BirthYear, S.Gender, S.SchoolState,
S.SchoolName, S.Classification, S.Major, S.EmailAddress

FROM Account A INNER JOIN Student S ON A.AccountID = S.AccountID
WHERE A. AccountID = @AccountID
GO

Can I accomplish my goal in a better more efficient way or do I need two
stored procedures?

Thanks!
Nov 21 '05 #1
1 979
Ask your question in sqlserver.programming group
"Leon" <vn*****@msn.com> wrote in message
news:ur**************@tk2msftngp13.phx.gbl...
I have a situation in which I need two stored procedures that do basically
the same thing,
but takes in a different parameter value and return less of the same data.
I wonder is it best to
do two different stored procedures or just one to accomplish my goal?

The first sp take in the @emailaddress parameter value and selects the
following values from two different table:
Username, Password, FirstName, LastName

for completeness here the full second sp....

CREATE PROCEDURE GetStudentDetail
@AccountID INT
AS
SELECT A.Username, A.Password, A.SecretQuestion, A.SecretAnswer,
A.RoleID, A.Active, S.FirstName, S.LastName,
S.BirthMonth, S.BirthDay, S.BirthYear, S.Gender, S.SchoolState,
S.SchoolName, S.Classification, S.Major, S.EmailAddress

FROM Account A INNER JOIN Student S ON A.AccountID = S.AccountID
WHERE A. AccountID = @AccountID
GO

Can I accomplish my goal in a better more efficient way or do I need two
stored procedures?

Thanks!

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tommynospam | last post by:
I've recently inhereted an environment in which we have over 600 stored procedures. The documentation is either very poor or non-existant and am needing advice on how to determine if a stored...
4
by: erich93063 | last post by:
I have a stored procedure which is performing a search against a "task" table. I would like to pass in a variable called @strAssignedTo which will be a comma delimeted list of employee ID's ie:...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
2
by: Mike Hutton | last post by:
I have a rather odd problem. I have a SP which uses temp. tables along the way, and then returns a table of results: CREATE PROCEDURE dbo.usp_myproc( @pNameList VARCHAR(6000) ) AS
2
by: Justin | last post by:
I am creating a web app for a client in VS.NET using ASP.NET with C#. I need to query three tables in a database using one parameter and display the results on the page. my question is should I use...
5
by: Leon | last post by:
I have a situation in which I need two stored procedures that do basically the same thing, but takes in a different parameter value and return less of the same data. I wonder is it best to do two...
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
3
by: CK | last post by:
Hi All, Quick question, I have always heard it best practice to check for exist, if so, drop, then create the proc. I just wanted to know why that's a best practice. I am trying to put that theory...
3
by: GaryDean | last post by:
In a new 2.0 website I am developing I am using .XSD tableadapters, building them with the wizard), and choosing the Stored Procedure option. I now notice that when I go back to change the sql...
2
by: Krij | last post by:
Hi, I'm a student and I have the following working example that troubles me (in SQL Server 2005): CREATE PROCEDURE dbo.CustomersOrderHistory ( @Firstname varchar(7) OUTPUT) AS SELECT ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.