Object_id function usage in SQL

Source: Internet
Author: User

When listing all the field names in the table, the following SQL function is used: object_id
Here I will list its functions and usage so that you can understand:

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)

Related Article

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.