Advanced PowerBuilder

HomePrevious Lesson: SQL Anywhere Stored Procedures
Next Lesson: Using a Stored Procedure In PowerScript

SQL Server Stored Procedures

On the other hand, SQL Server stored procedures are both powerful and flexible. You specify the OUTPUT keyword only for those parameters for which you want a value to be returned. You can specify default values and have as many SQL statements as you want. The syntax is as follows:
CREATE PROCEDURE Proc2 
@Product_balance int, @affected_count int =NULL OUTPUT 
as
SELECT product_no, product_description, product_balance
   FROM product_master 
   WHERE product_balance > @product_balance
SELECT @affected_count = @@rowcount
SELECT @affected_count
return (0)

Note that in SQL Server, there is no need to declare the result set.

To execute a SQL Server stored procedure in the Database Administration Painter, we would use the following:
EXECUTE Proc2 @product_balance = 100;

Note that you don't need to supply parentheses for the parameters, when executing a stored procedure residing in the SQL Server.
HomePrevious Lesson: SQL Anywhere Stored Procedures
Next Lesson: Using a Stored Procedure In PowerScript