dbo.Addresses

I just saved you a few minutes of time – you’re welcome!

IF NOT EXISTS ( SELECT *
                FROM   sys.Objects
                WHERE  object_id = OBJECT_ID(N'dbo.Addresses')
                       AND type in (N'U')
)
BEGIN
  CREATE TABLE dbo.Addresses (
     ID BIGINT PRIMARY KEY IDENTITY(1,1),
     AddressType INT , -- Foreign Key to AddressTypes table
     ContactID BIGINT , -- Foreign Key to a People or Contacts table
     PreDirectional NVARCHAR(20) , -- South, SW, NE, East
     StreetNo NVARCHAR(20) , -- location on street
     StreetName NVARCHAR(50) , -- name of the street, if applicable
     CrossStreetName NVARCHAR(50) , -- for purposes of wayfinding
     PostDirectional NVARCHAR(20) , -- South, SW, NE, East
     StreetType NVARCHAR(30) , -- Street, Road, Boulevard, Annex, Canyon
     UnitNo NVARCHAR(20) , -- Apt, Suite, etc.
     PostOfficeBox NVARCHAR(20) ,
     FloorNo NVARCHAR(20) ,
     BuildingNo NVARCHAR(20) ,
     BuildingName NVARCHAR(60) ,
     CampusName NVARCHAR(50) ,
     LotNo NVARCHAR(20) ,
     PlatNo NVARCHAR(20) ,
     PlatName NVARCHAR(20) ,
     CityNo BIGINT , -- FK to Cities.CityID
     CityName NVARCHAR(20) ,
     ParishName NVARCHAR(50) ,
     PostalCode NVARCHAR(10) , -- USPS, Canada and other foreign postal services
     MailStop NVARCHAR(20) ,
     USPS_StopCode BIGINT , -- USPS postal stop code
     Latitude DECIMAL (18,4) ,
     Longitude DECIMAL (18,4) ,
     CountyID BIGINT ,
     CountyName NVARCHAR(30) ,
     StateID INT ,
     StateAbbr NVARCHAR(20) ,
     CountryID INT ,
     RegionID INT ,
     MSACode NVARCHAR(20)
);
END
GO
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s