Monday, April 24, 2023

Sunday, April 23, 2023

Create Stored Procedure with output parameter and how to call stored procedure with output.

 Create proc with input parameter:

CREATE PROCEDURE Usp_GetEmployee

(

   @EmpId int

)

as

begin

select * from Emp where EmpId=@EmpId

end

 Create proc with Output parameter:

CREATE PROC Usp_OutPutEmp

(

  @EmpId int ,

  @empName varchar output

)

as 

begin

SELECT @empName= EmpName  FROM Emp WHERE EmpId=@EmpId

end


---------------------Call Proc with output Parameter------------


DECLARE @EmpName varchar(30)

exec Usp_OutPutEmp 1,@EmpName output

print @EmpName



How to remove dublicate record in a table

 DELETE P1 FROM ProductId AS P1

INNER JOIN PRODUCTID AS P2 ON

P1.ProductId>P2.ProductId AND P1.PName=P2.PName


How to use SQL pagination using LIMIT and OFFSET

  How to extract just a portion of a larger result set from a SQL SELECT. LIMIT n is an alternative syntax to the FETCH FIRST n ROWS ONLY. T...