Get a list of tables but not include system tables (SQL Server 2K)?

I know that I can get a list of tables from this database with the following query:

select * from information_schema.tables 

How can I exclude system tables?

+4
source share
4 answers
 select name from sysobjects where type='U' 
+4
source

I know this is a rather old question, but someone just edited it to resurrect it, and the “correct” answer from my point of view is not one of those listed. The accepted answer contains some “system” tables ( dtproperties is mentioned in the comments. If the user had any kind of replication, they would have found a few more).

Another answer uses a 2005 table, but that is almost correct. Instead of 2000, you want to use OBJECTPROPERTY :

 select name from sysobjects where OBJECTPROPERTY(id,N'IsTable')=1 and OBJECTPROPERTY(id,N'IsMSShipped')=0 
+4
source
 SELECT name FROM [database].sys.tables where is_ms_shipped=0 
+2
source

I know this is also an old question, but you can execute the sql server stored procedure:

EXEC sp_tables @table_name = "%", @table_owner = "%", @table_type = "'TABLE'"

and get a list of tables. But SQL 2K is not supported. There is a server since 2005 ...

0
source

Source: https://habr.com/ru/post/912500/


All Articles