Tuesday, May 22, 2012 12:19 PM
Hello all ,
I need to know how to list all table names in sql server 2005 as per dependability order.
for example below are three table in sql server 2005 database
County(id , name)
City(id, countryid, name)
Contact(id , cityid , name)
Account(id , contactid , name)
Contract(id accountid , name)
And we have fill above records in the same order because of foreign key constraint.
Like the same above . I have 150 tables in database and foreign key constraint between some tables.
Is there any script through which I can list out the table name in exact way like which need to fill first , second and so on...
Tuesday, May 22, 2012 6:52 PMI don't. However, before doing data imports, I have a script that drops all FK constraints. Then I do my updates in whatever order I want. Then I have a script that rebuilds my FK constraints.
Tuesday, May 22, 2012 8:13 PMThis forum is for Master Data Services, you may want to post this question to SQL Server Forum, more people will see your question there. :)
Yang Wang (Microsoft SQL Server Master Data Services)
Saturday, June 02, 2012 8:11 AMModerator
Please refer to the following T-SQL statement to get all tables in a database:
SELECT * FROM sys.Tables
Order by name ASC
If you have any more questions about T-SQL, I think that you can post the questions in SQL Server T-SQL forum.
TechNet Community Support
- Marked As Answer by Elvis LongMicrosoft Contingent Staff, Moderator Tuesday, June 05, 2012 5:26 AM
Saturday, January 05, 2013 6:11 AM
here where i can put my database name..if i dont know the database name ...how to find it.
i need query to find the database ,table name??