Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EXEC retrieve_customers_by_location 'Seattle','WA','98144','USA'
- CREATE PROC retrieve_customers_by_location(
- @city NVARCHAR(100),
- @state NVARCHAR(2),
- @zip NVARCHAR(9),
- @country NVARCHAR(10)
- )
- As
- Begin
- select * from customers where city=@city and state=@state and zip=@zip and country = @country
- End
- select * from customers
- where
- (city = @city or @city is null) and
- (state= @state or @state is null) and
- (zip = @zip or @zip is null) and
- (country = @country or @country is null)
- ID
- FIRST
- LAST
- CITY
- STATE
- ZIP
- COUNTRY
- 1
- Joe
- Public
- Seattle
- WA
- 98144
- USA
- 2
- Jane
- Public
- Amsterdam
- BT
- 1063
- NLD
- 3
- Jennifer
- Public
- Miami
- FL
- 33101
- NULL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement