SQL - Using Escape to exclude Audit Tables in Query

From ExxtremeWiki
Jump to: navigation, search

Simple Example of a Query using Escape with SQL Server[edit]

SELECT objectname, attributename, eauditenabled, esigenabled, remarks
	FROM maxattributecfg 
	WHERE objectname NOT LIKE 'A\_%' escape '\'
	and eauditenabled = 1
	order by objectname, attributename


The above query will exclude the "normal" Maximo audit tables from the results - excluded are those tables starting with A_ for example A_WORKORDER or A_PO - this is the most common audit table format in Maximo and is the default (although it can be changed). The problem here is that the underscore "_" is a wildcard that matches any one single character, without the escape any table starting with "A" will be excluded.


--Will (talk) 09:23, 8 May 2013 (CDT)