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

  • Home
  • SEARCH
  • 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 6119041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:30:21+00:00 2026-05-23T15:30:21+00:00

I’m trying to select various table and column names from a (SQL Server 2008)

  • 0

I’m trying to select various table and column names from a (SQL Server 2008) database. The database is fairly big. There are several databases sitting on the same server, each with various schemas etc. Once there’s a multi-part identifier involved I’m stuck. For example, to retrieve a list of tables in under a database this works fine:

SELECT [name]
FROM DatabaseOne.sys.tables
ORDER BY [name]

Then I want to get the tables under a certain schema. E.g.:

SELECT [name]
FROM DatabaseOne.SchemaOne.sys.tables
ORDER BY [name]

But I get the error:

Could not find server ‘DatabaseOne’ in sys.servers. Verify that the
correct server name was specified. If necessary, execute the
stored procedure sp_addlinkedserver to add the server to sys.servers.

A large part of the problem probably lies in the fact that I don’t really know anything about schemas (if that’s even what they are).

Also, if I want to find the column names in a table, say DatabaseOne.SchemaOne.TableOne, how would I go about doing that?

Any help would be highly appreciated.

  • 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-23T15:30:22+00:00Added an answer on May 23, 2026 at 3:30 pm

    If you use a four part name, SQL Assumes the first portion is the name of a linked server.

    The system tables are in the sys schema, and contain data for all other schemas like dbo or whatever.

    In sys.tables there is a schema_id value that specifies which schema each table is in. There is also a sys.schemas table which contains the schemas.

    If you know your schema name, you can do a

    SELECT [name]
    FROM DatabaseOne.sys.tables t
    INNER JOIN sys.schemas s
        ON s.schema_id = t.schema_id
    WHERE s.name = 'MySchema'
    ORDER BY [name]
    

    You can also check multiple schemas by making the s.name evaluation an IN evaluation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this live SQL Server 2008 (build 10.0.1600) database, there's an Events table, which
I'm trying to select a column from a single table (no joins) and I
I'm trying to select more than 80,000 record in SQL Server in a table
I'm trying to select data from a table defined similar to the following :
I'm trying to select a random 10% sampling from a small table. I thought
I'm trying to write a SQL Server database update script. I want to test
I am trying to merge records from an Oracle database table to my local
I am trying to calculate the median from a table with various types of
I'm trying to select the name field from the author node in an ATOM
I am trying to select certain fields from my entity to be used as

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.