CREATE PROCEDURE statement [T-SQL]

Description

Creates a new procedure in the database in a manner compatible with Adaptive Server Enterprise.

Syntax

This subset of the Transact-SQL CREATE PROCEDURE statement is supported in Sybase IQ:

CREATE PROCEDUREowner.]procedure_name
… [ [ ( ] @parameter_name data-type [ = default ] [ OUTPUT ] [ , … ] [ ) ] ]
…[ WITH RECOMPILE ]
… ASstatement-list

Usage

The following differences between Transact-SQL and Sybase IQ statements are listed to help those writing in both dialects.

CREATE PROCEDURE showdept @deptname varchar(30)
AS
  SELECT Employees.Surname, Employees.givenName
  FROM Departments, Employees
  WHERE Departments.DepartmentName = @deptname
  AND Departments.DepartmentID =
        Employees.DepartmentID

This is the corresponding Sybase IQ procedure:

CREATE PROCEDURE showdept(in deptname 
      varchar(30) )
RESULT ( lastname char(20), firstname char(20))
ON EXCEPTION RESUME
BEGIN
  SELECT Employees.SurName, Employees.GivenName
  FROM Departments, Employees
  WHERE Departments.DepartmentName = deptname
  AND Departments.DepartmentID =
        Employees.DepartmentID
END

NoteThere are two ways to create stored procedures: T-SQL and SQ/92. BEGIN TRANSACTION, for example, is T-SQL specific when using CREATE PROCEDURE syntax. Do not mix syntax when creating stored procedures.


Side effects

Automatic commit.

Standards

Permissions

Must have RESOURCE authority.

See also

CREATE PROCEDURE statement