If object_id is not null
On the other way, the second query uses the appropriate view for checking the existence of the foreign key, where it'll always be found if it exists.
In fact, MSDN has almost your very same code as an example of this behavior, only for a trigger instead:. For objects that are not found in the sys. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more.
Ask Question. Asked 3 years, 9 months ago. Active 3 years, 8 months ago. Viewed 1k times. Especially because the first query did use to work.
Improve this question. You're just missing the object type parameter. For a list of object types, see the type column in sys. A user can only view the metadata of securables that the user owns or on which the user has been granted permission.
For more information, see Metadata Visibility Configuration. When the parameter to a system function is optional, the current database, host computer, server user, or database user is assumed. Built-in functions must always be followed by parentheses.
When a temporary table name is specified, the database name must come before the temporary table name, unless the current database is tempdb. System functions can be used in the select list, in the WHERE clause, and anywhere an expression is allowed. The following example returns the object ID for the Production. WorkOrder table in the AdventureWorks database. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Learn more. Ask Question. Asked 3 years, 4 months ago. Active 3 years, 4 months ago. Viewed 9k times. Did I missed anything? Can anyone explain this difference between tables to triggers and views? Note: I'm using sql server Improve this question.
0コメント