Answers for "stored procedure"

SQL
8

sql server stored procedure

CREATE PROCEDURE spGetEmployeeCountByGender
@Gender nvarchar(20),
@EmployeeCount int Output
AS
BEGIN
SELECT @EmployeeCount = COUNT(Id) 
FROM tblEmployee 
WHERE Gender = @Gender
END
Posted by: Guest on February-17-2021
0

create select stored procedure in sql server

CREATE PROCEDURE sp_getRaces
AS
BEGIN 
SELECT * FROM dbo.Races
END ;
Posted by: Guest on November-09-2020
2

Explain the Stored Procedure

Stored Procedure :
A stored procedure is a prepared SQL code that you can save, 
so the code can be reused over and over again.

So if you have an SQL query that you write over and over again, 
save it as a stored procedure, and then just call it to execute it.

You can also pass parameters to a stored procedure, 
so that the stored procedure can act based on the parameter value(s) 
that is passed.
Posted by: Guest on July-10-2021
3

create proc

IF OBJECT_ID ( 'Production.uspGetList', 'P' ) IS NOT NULL   
    DROP PROCEDURE Production.uspGetList;  
GO  
CREATE PROCEDURE Production.uspGetList @Product varchar(40)   
    , @MaxPrice money   
    , @ComparePrice money OUTPUT  
    , @ListPrice money OUT  
AS  
    SET NOCOUNT ON;  
    SELECT p.[Name] AS Product, p.ListPrice AS 'List Price'  
    FROM Production.Product AS p  
    JOIN Production.ProductSubcategory AS s   
      ON p.ProductSubcategoryID = s.ProductSubcategoryID  
    WHERE s.[Name] LIKE @Product AND p.ListPrice < @MaxPrice;  
-- Populate the output variable @ListPprice.  
SET @ListPrice = (SELECT MAX(p.ListPrice)  
        FROM Production.Product AS p  
        JOIN  Production.ProductSubcategory AS s   
          ON p.ProductSubcategoryID = s.ProductSubcategoryID  
        WHERE s.[Name] LIKE @Product AND p.ListPrice < @MaxPrice);  
-- Populate the output variable @compareprice.  
SET @ComparePrice = @MaxPrice;  
GO
Posted by: Guest on March-17-2020
0

sql procedure

CREATE OR REPLACE PROCEDURE my_scheme.my_procedure(param1 IN VARCHAR2) IS
    cnumber NUMBER;
BEGIN
    cnumber := 10;
    INSERT INTO my_table (num_field) VALUES (param1 + cnumber);
    COMMIT;
EXCEPTION
    WHEN OTHERS THEN
        raise_application_error(-20001, 'An error was encountered - '
            || sqlcode || ' -ERROR- ' || sqlerrm);
END;
Posted by: Guest on April-24-2021
0

what is a stored procedure

SQL Stored Procedure
Posted by: Guest on September-28-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language