sql server - How to find all objects in a database that use UNION -


how can find views , sp's contains union keyword?

(alternate question: in system table stored text of sp's , views)

thank you

here naive workable example: (tested on sql server 2005 & 2008 r2)

use msdb;  select * sys.all_sql_modules   (definition '%create view%' or   definition '%create procedure%') , definition '%union%' 

to solidify join via object_id link , filter views , stored procs object type rather using like.

simpler:

select * sys.all_sql_modules definition '%union%' 

caveat: since we're performing comparison against create script of each object pick on word union if/when appears in comments. might ok if need results more deterministic , avoid such cases clause need more complex, possibly using regex refine results.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -