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 6805691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:37:03+00:00 2026-05-26T19:37:03+00:00

I am working with SQL Server 2008 R2. I want to query a database

  • 0

I am working with SQL Server 2008 R2. I want to query a database and retrieve all user defined tables (easy enough, SELECT Name FROM sys.tables), but I want it to be ordered so that if insert statements were executed in that order, they would not run into foreign key constraints.

In other words, I want the list of tables sorted by dependencies so that the highest level tables (i.e. the ones that had no dependencies) are before those that rely on them.

What is the most efficient way to query this?

Thanks for any help.

  • 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-26T19:37:04+00:00Added an answer on May 26, 2026 at 7:37 pm

    Does the ”top-down hierarchy” query discussed on http://www.jasinskionline.com/technicalwiki/Default.aspx?Page=List-Tables-in-Dependency-Order-SQL-Server&NS=&AspxAutoDetectCookieSupport=1 produce the list you’re looking for?

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

Sidebar

Related Questions

I want to return all rows from a SQL Server 2008 database table into
I'm working on a multi-user internet database-driven website with SQL Server 2008 / LinqToSQL
I'm working on performance tuning my SQL Server 2008 database and am using the
I am working with SQL Server and I want to set the Database password
I have two tables in a SQL Server 2008 database in my company. The
I'm working with SQL Server 2008. Let's say I have these three tables: Product
I'm working with SQL server 2008, and I want to create in my first
I have a live SQL Server 2008 database and I need to start working
I'm working on a C# project using a SQL Server 2008 database. There are
I am working on a project which uses a relational database (SQL Server 2008).

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.