February 4, 2013 at 1:06 pm
It is for SQL 2008.
Many thanks in advance.
February 4, 2013 at 1:15 pm
it's all in sys.tables, but i prefer to use built in functions instead of joining sys.schemas:
SELECT
SCHEMA_NAME(schema_id) As SchemaName ,
name As TableName
from sys.tables
ORDER BY name
--alternate:
SELECT
sch.name As SchemaName ,
tbl.name As TableName
from sys.tables tbl
inner join sys.schemas sch on tbl.schema_id = sch.schema_id
ORDER BY tbl.name
Lowell
February 4, 2013 at 2:04 pm
I typically just go for sys.objects like the following.
SELECT SCHEMA_NAME(schema_id) As SchemaName
,name As TableName
FROM sys.objects
WHERE type = 'U'
An interesting sidebar on this is that if you look at the execution plan, the version going to sys.tables will get it's data from sysschobjs and sysidxstats and will cost a little bit more than just going direct to sys.objects (for which sysschobjs is the base object).
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
February 4, 2013 at 4:17 pm
You can also use the following:
SELECT Table_Schema, Table_Name
FROM information_schema.tables
WHERE table_type = 'BASE TABLE'
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy