Question: Create user-defined functions that replicate the following: 1. CONCAT(HotelHNumber,' ' , HotelStreet,' ' , HotelCity,' ' , HotelState, ' ' , HotelZip) 2. CONCAT(CustomerHNumber,' '
Create user-defined functions that replicate the following:
1. CONCAT(HotelHNumber,' ' , HotelStreet,' ' , HotelCity,' ' , HotelState, ' ' , HotelZip)
2. CONCAT(CustomerHNumber,' ' , CustomerStreet,' ' , CustomerCity,' ' , CustomerState, ' ' , CustomerZip)
The goal is to make a function that automatically takes those inputs and turns them into a full address.
Two tables for reference:


CREATE TABLE Customer ( CustomerID INT FirstName VARCHAR(30) LastName VARCHAR(30) CustomerPhone VARCHAR(12) Customer Email VARCHAR (35) CustomerHNumber INT CustomerStreet VARCHAR (30) CustomerCity VARCHAR (30) CustomerState CHAR(2) CustomerZip INT ); NOT NULL NOT NULL, NOT NULL, NOT NULL NOT NULL, NOT NULL, NOT NULL, NOT NULL, NOT NULL, NOT NULL IDENTITY PRIMARY KEY, UNIQUE CHECK (CustomerPhone LIKE '[0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'), --phone number format CHECK (CustomerState LIKE '[A-Z][A-Z]'), --only allows state abbreviation CHECK (CustomerZip LIKE '[0-9][0-9][0-9][0-9][0-9]') --zip code is always 5 digits
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
