October 12, 2008 at 12:17 pm
This is my attempt to create a stored procedure that returns a status based on conditions in other fields. I set it up as a CASE statement since I plan on adding other criteria for other statuses once I get it working. It says that CaclulatedStatus is an invalid column name:
Invalid column name 'CalculatedStatus'.
CREATE PROCEDURE dbo.sp_Chop_Status
@Chop_ID nVarChar(6) = NULL,
@Contract_Level nVarChar(1) = NULL,
@status nVarChar(20) OUTPUT
AS
BEGIN
/* SET NOCOUNT ON */
SELECT
[CHOP ID],
[CONTRACT LEVEL],
[ARRIVAL DATE],
SPOT,
CASE
WHEN Spot = 'Y' THEN 'Spot'
WHEN Spot <> 'Y' THEN 'To Arrive'
END
AS CalculatedStatus
FROM DBO.CHOPS
WHERE (([CHOP ID] = @CHOP_ID)
AND ([CONTRACT LEVEL] = @Contract_Level))
SET @status = CalculatedStatus
END
RETURN
How do I return the status?
"What I lack in youth I make up for in immaturity!"
Please visit my music site at http://woundedego.com
October 12, 2008 at 12:19 pm
Duplicate post.
Replies to the following thread please:
http://www.sqlservercentral.com/Forums/Topic584586-1292-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply