Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

select *
from information_schema.tables

How do I go about excluding system tables though?

like image 236
Sonny Boy Avatar asked Jul 09 '10 20:07

Sonny Boy


1 Answers

I know this is quite an old question, but someone's just edited it to resurrect it, and the "right" answer from my perspective isn't either of the two listed. The accepted answer includes some "system" tables (dtproperties is mentioned in the comments. If the user had any replication going on, they'd have found a few more).

The other answer uses a 2005 table, but is so nearly correct. For 2000, you want to use OBJECTPROPERTY instead:

select name from sysobjects where
    OBJECTPROPERTY(id,N'IsTable')=1 and
    OBJECTPROPERTY(id,N'IsMSShipped')=0
like image 122
Damien_The_Unbeliever Avatar answered Oct 05 '22 21:10

Damien_The_Unbeliever