Showing posts with label functions. Show all posts
Showing posts with label functions. Show all posts

Wednesday, March 28, 2012

info..._schema.routines no Triggers listed - how to find scripts?

Hello,
when I look through Informatin_Schema.Routines I can find listings and
scripts for stored procedures and user-defined functions. Besides the
Trigger Manager, where can I find a collective listing of all Triggers in a
DB and the corresponding scripts? What I really want to do is to find a
Trigger that is using a particular UDF. In pseudo code I was hoping to do
something like this:
Select Routine_Name From Information_Schema.TriggerRoutines Where
Routine_Definition Like %dbo.f_someUDF%
Any suggestions appreciated how I can accomplish this.
Thanks,
Rich>What I really want to do is to find a
> Trigger that is using a particular UDF. In pseudo code I was hoping to do
> something like this:
If that's all that you really want to do, assuming that the trigger and the
function are in the same database
SQL 2000:
select DISTINCT OBJECT_NAME([id]) FROM sysdepends
WHERE OBJECT_NAME([depid]) = 'YourFunction'
SQL 2005
SELECT DISTINCT OBJECT_NAME([id]) FROM sys.sql_dependencies
WHERE OBJECT_NAME([referenced_major_id]) = 'YourFunction'
If you posted to this forum through TechNet, and you found my answers
helpful, please mark them as answers.

Monday, March 19, 2012

Indexing on Views

1) We have SQL Server 2005 database on windows 2003 server.

2) What about columns in functions i.e. SUM(ABS(Col1)) OR SUM(Col2 * Col3). We create a view to select these and index on view on its computed AS column? Can we directly use vw1.AScol in query in place of these function expressions? Will the index be picked and how will cost improvement compare with that of index on normal columns.

3) Can statistics be used in such a situation?

its possible to put indexes on this columns...and it will be picked .... have a look at this link.:

http://www.microsoft.com/technet/prodtechnol/sql/2005/impprfiv.mspx