0

Consider I have a table with different columns types:

CREATE TABLE [RentedHome]
(
     [HomeID] INT NOT NULL PRIMARY KEY CLUSTERED,
     [Address] CHAR (255) NOT NULL CHECK (LEN(Address) >= 2),
     [Landlord] CHAR (100) NOT NULL CHECK (LEN(Landlord) >= 2),
     [Tenant] CHAR (100) NOT NULL CHECK (LEN(Landlord) >= 2),
)

I want to add the Geography column to the mentioned table, how should I define the column (I want to insert just a geography-point for each home):

[Location] GEO (yyy)

Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
amin
  • 93
  • 8
  • There is no such thing as a **SQL database** - SQL is just the Structured Query Language - a language used by most relational database systems, but it's not a database product. Many things are vendor-specific - so we really need to know what concrete database system (and which version) you're using.... (please update tags accordingly) – marc_s Mar 27 '22 at 13:48

1 Answers1

0

Done!

CREATE TABLE [RentedHome]
(
      [HomeID] INT NOT NULL PRIMARY KEY CLUSTERED,
      [Address] CHAR (255) NOT NULL CHECK (LEN(Address) >= 2),
      [Landlord] CHAR (100) NOT NULL CHECK (LEN(Landlord) >= 2),
      [GeoLocation] geography,
      [Tenant] CHAR (100) NOT NULL CHECK (LEN(Tenant) >= 2),
)

inserting example:

INSERT INTO [RentedHome] 
VALUES (1, '177 Huntington Ave #1010, Boston, MA 02115, United States', 'Northeastern University', geography::Point(42.34497193099456, -71.08252116132054, 4326), 'Network Lab')
amin
  • 93
  • 8