Richard
Richard

Reputation: 588

How I can save all the names of my tables into a new table from sql?

I have a huge database in Sql-Server and I need to get all the names of the tables into one new table that I have made. This can be done? I appreciate your help. The new table has the fields ID, TableName, Status. Id is the identity and status for now will be 1, not null

Upvotes: 1

Views: 566

Answers (1)

yogihosting
yogihosting

Reputation: 6292

Use this query below to get all tables name from your database

SELECT name FROM sys.tables

Then you can do a insert query like -

insert into newtable(name) select * from sys.tables

Upvotes: 3

Related Questions