List all tables in the database

Source: Internet
Author: User

Select name from sysobjects where type = 'U'

Select count (*) from sysobjects where id = object_id ('database name. Owner. Table name ')

 

Object_id
Returns the ID of the database object.

Syntax
Object_id ('object ')

Parameters
'Object'

The object to use. The object data type is Char or nchar. If the object data type is Char, It is implicitly converted to nchar.

Return type
Int

Note
When this parameter is optional for system functions, the system uses the current database, host, server user, or database user. The built-in function must be followed by parentheses.

If you specify a temporary table name, you must add a database name before the temporary table name. For example:

Select object_id ('tempdb .. # mytemptable ')

System functions can be used in the selection list, where clause, and any place where expressions are allowed. For more information, see expressions and where.

Example
The following example shows the ID of the object returned from the authors table in the pubs database.

Use master
Select object_id ('pubs .. Authors ')

The following is the result set:

-----------
1977058079

(1 row (s) affected)

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.