Let us assume that I have a table called Sales.Invoices from database WideWorldImporters. Let us use the function OBJECTPROPERTY to figure out if it is a view or table.
SELECT OBJECTPROPERTY(OBJECT_ID(N'Sales.Invoices'), 'IsTable') IsTable, OBJECTPROPERTY(OBJECT_ID(N'Sales.Invoices'), 'IsView') IsView
When you run the script above you will get the following result.
As you can see, I can easily figure out the object property with the function. Personally, I use this function for quite a lot of things during my consultancy engagement. Let me know if you are interested to know more about this topic and I will write more blogs as well as create an SQL in Sixty Seconds video.
Here are my few recent videos and I would like to know what is your feedback about them.
- Find Expensive Queries – SQL in Sixty Seconds #159
- Case-Sensitive Search – SQL in Sixty Seconds #158
- Wait Stats for Performance – SQL in Sixty Seconds #157
- Multiple Backup Copies Stripped – SQL in Sixty Seconds #156
Reference: Pinal Dave (https://blog.sqlauthority.com)