CREATE PROCEDURE [dbo].[Procedure_table]
(@records INT OUTPUT,
@location nvarchar(18) = NULL,
@exclude tinyint = NULL,
@exclude2 tinyint = NULL,
@locationName nvarchar(50) = NULL,
@Adult tinyint = NULL, ,
@Youth nvarchar(8) = NULL,
@Case nvarchar(50) = NULL,
@explanation nvarchar(50) = NULL,
@FirstName nvarchar(50) = NULL,
@LastName nvarchar(50) = NULL,
@PhoneNumber nvarchar(50) = NULL,
@orderField nvarchar(50) = NULL,
@orderDir nvarchar(4) = NULL)
If @orderField IS NULL
SET @orderField = 'ID'
If @orderDir IS NULL
SET @orderDir = 'ASC'
WHERE 1 = 1 AND
Code = ISNULL(@location, Code) AND
Exclusion <= ISNULL(@exclude, Exclusion) AND
Exclusion >= ISNULL(@exclude2, Exclusion) AND
Adult = ISNULL(@Adult, Adult) AND
Youth LIKE ISNULL('%' + @Youth + '%', Youth) AND
LocationName LIKE ISNULL ('%' + @LocationName + '%', LocationName) AND
I am currently rewriting a database to learn more about sql, I have hit a point in procedures that I can't piece together.
Any direction much appreciated,
Essentially what this procedure is saying pull ID through explanation from dbo.table, and placing the data in procedure_table. I don't understand what the @variables are after Create Procedure? Once I understand that I can better interpret what the 'WHERE' is truly doing. Thank you.