Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 516 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I get list of all tables in a database using TSQL?

#1
What is the best way to get the names of all of the tables in a specific database on SQL Server?
Reply

#2
exec sp_msforeachtable 'print ''?'''
Reply

#3
`select * from sysobjects where xtype='U'`
Reply

#4
SELECT sobjects.name
FROM sysobjects sobjects
WHERE sobjects.xtype = 'U'
Reply

#5
SELECT name
FROM sysobjects
WHERE xtype='U'
ORDER BY name;

(SQL Server 2000 standard; still supported in SQL Server 2005.)
Reply

#6
SELECT * FROM information_schema.tables
where TABLE_TYPE = 'BASE TABLE'
SQL Server 2012
Reply

#7
SELECT sobjects.name
FROM sysobjects sobjects
WHERE sobjects.xtype = 'U'

Here is a list of other object types you can search for as well:

- AF: Aggregate function (CLR)
- C: CHECK constraint
- D: Default or DEFAULT constraint
- F: FOREIGN KEY constraint
- L: Log
- FN: Scalar function
- FS: Assembly (CLR) scalar-function
- FT: Assembly (CLR) table-valued function
- IF: In-lined table-function
- IT: Internal table
- P: Stored procedure
- PC: Assembly (CLR) stored-procedure
- PK: PRIMARY KEY constraint (type is K)
- RF: Replication filter stored procedure
- S: System table
- SN: Synonym
- SQ: Service queue
- TA: Assembly (CLR) DML trigger
- TF: Table function
- TR: SQL DML Trigger
- TT: Table type
- U: User table
- UQ: UNIQUE constraint (type is K)
- V: View
- X: Extended stored procedure

Reply

#8
--for oracle
select tablespace_name, table_name from all_tables;

---------------------------------------------
This link can provide much more information on this
[topic][1]




[1]:

[To see links please register here]

Reply

#9


SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE='BASE TABLE'
ORDER BY TABLE_NAME
Reply

#10
Thanks to Ray Vega, whose response gives all user tables in a database...

> exec sp_msforeachtable 'print ''?'''

sp_helptext shows the underlying query, which summarises to...

select * from dbo.sysobjects o
join sys.all_objects syso on o.id = syso.object_id
where OBJECTPROPERTY(o.id, 'IsUserTable') = 1
and o.category & 2 = 0
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through