What is Object_id in MS SQL

Hello everybody,

today I want to leave a short notice on OBJECT_ID in MS SQL.

Quite often I've seen sql like this:

IF OBJECT_ID(N'dbo.Students', N'U') IS NOT NULL DROP TABLE dbo.Students;

Today I have found time to discover what it actually means. 

OBJECT_ID is function, that checks wheather object exists or not. It accepts two parameters: object name and object type. In my case object name is dbo.Students, object type U is internal representation of table.

No Comments

Add a Comment