jeudi 12 mai 2016

Use IF / ELSE IF on STORED PROCEDURE in Sql Server 2005

I have problem with this STORED PROCEDURE in Sql Server.

Any value entered as a parameter extracts data with parameter 'S'.

Can you please help me figure out the problem?

Thanks in advance.

My code below.

ALTER PROCEDURE [dbo].[xxxx](@StartDate VARCHAR(10),@EndDate VARCHAR(10),@Parameter CHAR(1)) 
AS
IF @Parameter='S'
    BEGIN
    SELECT * FROM doTable_S

END

ELSE IF @Parameter='A'
    BEGIN
    SELECT * FROM doTable_A
END

Aucun commentaire:

Enregistrer un commentaire