Important alert: (current site time 7/15/2013 7:16:23 PM EDT)
 

VB icon

OBJECTPROPERTY (Example: Is Trigger Disabled)

Email
Submitted on: 2/4/2002 6:57:07 AM
By: James Travis  
Level: Advanced
User Rating: By 3 Users
Compatibility: SQL Server 7.0, Other
Views: 14069
author picture
(About the author)
 
     OBJECTPROPERTY allows you to glean a little more usefully information concerning many aspects of your database. In this example I will demonstrate ho to use it to check if a trigger is in a disabled state or not. (For more options see SQL Books Online).
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
--**************************************
-- Name: OBJECTPROPERTY (Example: Is Trigger Disabled)
-- Description:OBJECTPROPERTY allows you to glean a little more usefully information concerning many aspects of your database. In this example I will demonstrate ho to use it to check if a trigger is in a disabled state or not. (For more options see SQL Books Online).
-- By: James Travis
--
-- Inputs:OBJECTPROPERTY ( id , property )
--
-- Returns:In most cases 1 for True and 0 for False (Again see SQL Books Online for specific property options)
--
-- Assumes:For this example keep in mind one of the biggest problems you can have is trying to determine is why a specific trigger is not working. Sometimes this can be due to a disabling of a trigger done for whatever reason and inadvertently left isabled. This provides a simplistic way to quickly check first before you spend hours trying to find this simple mistake. (Also note: I am using OBJECT_ID so I can input the name which is more user friendly than me looking up the ID myself.)
--
--This code is copyrighted and has-- limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=399&lngWId=5--for details.--**************************************

SELECT OBJECTPROPERTY(OBJECT_ID('YourTriggerNameHere'),'ExecIsTriggerDisabled')
 
 
The above is just one example of information available thru OBJECTPROPERTY. You also have many more, such as:
 
CnstIsDisabled to determine if a constraint is disabled.
 
CnstIsNotRepl to identify if a constraint is being replicated to another server.
 
IsCheckCnst to determine a constraint is a check type constraint.
 
IsIndexed to check if a table (or view) has an index.
 
TableHasClustIndex to make sure a table has a clustered index.
 
For more options check out SQL Books Online.


Other 20 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

5/7/2003 3:43:11 AM

I'm now doing the website that need to include the access database and lotus approach and some other system that still use offline cannot access through internet. How can i put online or convert this system to online? Thank you for your kindness, this not for commercial use just for my research. You can email to me at msha.dawang01@mmu.edu.my or mdsha77@yahoo.com
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.