| Author: D.Jeya kumar(JK) 09 Oct 2008 | Member Level: Diamond | Rating:    Points: 6 |
Hi,
Begin should end with End
check the below modified code
@category varchar(200) as if @category = 1 begin select top 20 * from educationmaster where isapproved = 1 end else if(@category)= 2 begin select top 20 * from educationmaster where isapproved = 0 end else if(@category)= 3 begin select top 20 * from educationmaster end
Regards JK
Note: please rate it if it is usefull
|
| Author: Mathew Philip 09 Oct 2008 | Member Level: Gold | Rating:  Points: 6 |
Hello,
Check the sample code
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Mathew Philip -- Create date: 09-Oct-2008 -- Description: Example -- ============================================= CREATE PROCEDURE MathewsExample (@a INT) AS BEGIN
DECLARE @b INT SET @a = 1
IF @a = 0 BEGIN SET @b = 10 END ELSE IF @a = 1 BEGIN SET @b = 20 END ELSE BEGIN SET @b = 30 END
END GO
Depending on the requirement you can use ELSE or ELSE IF in the last block of the ELSE IF ladder.
regards Mathew
|