Hello everyone,
Here is my current implementation of a stored procedure which returns Order status for a given Order ID. There are two situations,
- there is matched Order ID and I will retrieve the related status,
- there is no matched Order ID (i.e. non-existing Order ID).
My confusion is, how to implement the two functions elegantly/efficiently in one stored procedure, so that I return matched Order ID for situation 1 and also indicate client no matched Order ID in situation 2?
I am using VSTS 2008 + C# + ADO.Net + .Net 3.5 as client, and using SQL Server 2008 as server.
CREATE PROCEDURE [dbo].[GetStatus]
@ID [nvarchar](256),
@Status [int] output
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT @Status = [Status]
FROM [dbo].[OrderStatus]
WHERE (@ID = [ID]);
END
thanks in advance, George