Defines the name and type of local variables for a batch or procedure and defines cursors.
DECLARE @variable_name datatype
[, @variable_name datatype...]
where
This example is a stored procedure (reptq3) from the pubs database. This stored procedure uses three variables declared as input parameters.
CREATE PROCEDURE reptq3 @lolimit money, @hilimit money,
@type char(12)
AS
SELECT pub_id, type, title_id, price
FROM titles
WHERE price > @lolimit
AND price < @hilimit
AND type = @type OR type LIKE '%cook%'
ORDER BY pub_id, type
COMPUTE count(title_id) BY pub_id, type
| Batches | |
| Control-of-Flow Language | RAISERROR |
| CREATE PROCEDURE | SELECT |
| Cursors | UPDATE |
| Datatypes | Variables |
| EXECUTE |