Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6840707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:52:36+00:00 2026-05-26T23:52:36+00:00

First, I have created a table called Placemarks containing a column of type ‘geography’.

  • 0

First, I have created a table called Placemarks containing a column of type ‘geography’.

CREATE TABLE [dbo].[Placemarks](
[ID] [int] NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[Location] [geography] NOT NULL,
CONSTRAINT [PK_Placemarks] 
    PRIMARY KEY CLUSTERED([ID] ASC)
)

Then, I use the following query in a stored procedure to get a list of all columns in the table with their data types.

SELECT 
   b.name, c.name as TypeName, b.length, b.isnullable, b.collation, b.xprec, b.xscale
FROM sysobjects a 
inner join syscolumns b on a.id = b.id 
inner join systypes c on b.xtype = c.xtype and c.name <> 'sysname' 
WHERE a.id = object_id(N'[dbo].[Placemarks]') 
and OBJECTPROPERTY(a.id, N'IsUserTable') = 1 
ORDER BY b.colId

The result of the query can be viewed here:

Query results

I am using this query in a stored procedure and need to get a single row for each column in my Placemarks table. I could filter out rows with TypeName = geometry or hierarchyid.

But I may use the geometry datatype in the future and want the query to be forward compatible. Any other ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:52:37+00:00Added an answer on May 26, 2026 at 11:52 pm

    I would recommend using the newer sys system catalog views rather than the old sysobjects and similar views – those will be removed soon.

    With this query, you should get your desired result:

    SELECT
        c.name 'ColName',
        ty.Name 'TypeName',
        c.max_length, c.is_nullable, c.collation_name, c.precision, c.scale
    FROM
        sys.tables t
    INNER JOIN 
        sys.columns c ON t.object_id = c.object_id
    INNER JOIN  
        sys.types ty ON c.user_type_id = ty.user_type_id
    WHERE   
        t.name = 'Placemarks'
    

    At least in my case, I now get:

    ColName  TypeName    max_length is_nullable  collation_name  precision  scale
    ID       int           4            0        NULL                10       0
    Name     nvarchar    100            0        Latin1_General_CI_AS 0       0
    Location geography    -1            0        NULL                 0       0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table called Tournaments which is created using the EF code first
I'm new to NHibernate and trying to create my first mapping. I have created
I have the old legacy table called DXFTACCTS, and I created Rails model Account.
I have this in my table model called Table $test = $this->find('first', array( 'conditions'
We have a table called Contracts. These contract records are created by users on
I have created a file argument.pl which takes several arguments first of which should
Let me first describe my goal: I have created an object with 3 properties:
I am trying to write my first WCF project. I have created a project
I have a big project that was first created in Borland C++ 6. We're
I have a folder with these files: alongfilename1.txt <--- created first alongfilename3.txt <--- created

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.