The object_id () function in SQL SERVER

Source: Internet
Author: User
Tags visibility

Syntax : object_id (' [database_name. [Schema_name]. | Schema_name. ] object_name ' [, ' object_type '])

Parameters :

'  object_name '

The object to use. The data type of the object_name is varchar or nvarchar. If the object_name data type is varchar, it is implicitly converted to nvarchar. You can choose whether to specify a database and schema name.

'  object_type '

The schema-scoped object type. The data type of the object_type is varchar or nvarchar. If the object_type data type is varchar, it is implicitly converted to nvarchar. For a list of object types, see the Type column in sys.objects (Transact-SQL).

return type :int

Abnormal:

For spatial indexes, OBJECT_ID returns NULL.

When an error occurs, NULL is returned.

The user can only view the metadata of the securable object it owns, or the security object to which the permission has been granted. That is, if the user does not have any permissions on the object, some built-in functions that produce metadata, such as object_id, may return NULL. For more information, see Troubleshooting Metadata visibility configuration and metadata visibility.

Comments:

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

When you specify a temporary table name, you must precede the temporary table name with the database name unless the current database is tempdb. For example: SELECT OBJECT_ID(‘tempdb..#mytemptable‘) .

System functions can be used in select lists, where clauses, and wherever expressions are allowed to be used. For more information, see Expressions (Transact-SQL) and WHERE (Transact-SQL).

Category: Databases

The object_id () function in SQL SERVER

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.