A user can search for a customer by Firstname, LastName and optionally entering a City.
只有在用户使用动态结构进入一个W/o时,才有可能写出一个与CITY相对应的Q。
CREATE PROCEDURE [dbo].[SearchCustomer]
@FirstName varchar(30) --REQUIRED
@LastName varchar(30)--REQUIRED
@City varchar(30) --OPTIONAL
AS
SELECT * FROM CUSTOMER C WHERE
C.FirstName = @FirstName AND
C.LastName = @LastName AND
C.City = IsNull(@City, C.City) --This won t Work if CITY is optional in the database