Back to OIM Explorer

dbo.QBM_FGIAgentServiceRunning

Scalar FunctionSQL_SCALAR_FUNCTIONSandbox DB

Scalar Function.

Source: sandbox-db sys.sql_modules

Source size: 669 characters

Interpretation

  • Database function. Usually supports views, validation, or calculated predicates; look at referenced-by entries for callers.

Relations

  • No extracted relations.

Typed Edges

  • No typed edges extracted for this source.

References

  • No direct source references extracted.

Referenced By

  • No direct source references extracted.

Complete Source

SQL27 lines
1CREATE FUNCTION dbo.QBM_FGIAgentServiceRunning(2) RETURNS int3AS4BEGIN5  RETURN(6  SELECT TOP 1 CASE7  WHEN isnull(HAS_PERMS_BY_NAME('sys.dm_exec_sessions', 'Object', 'SELECT'), 0) = 0 THEN8  19  WHEN isnull(HAS_PERMS_BY_NAME(NULL, NULL, 'VIEW SERVER STATE'), 0) = 0 THEN10  111  WHEN EXISTS(12  SELECT TOP 1 113  FROM sys.dm_exec_sessions a14    WITH(nolock)15  WHERE16    a.database_id = DB_ID() AND a.session_id <> @@SPID AND(a.program_name = 'OneIM_DatabaseAgent')) THEN17  118  WHEN EXISTS(19  SELECT TOP 1 120  FROM sys.dm_exec_sessions a21    WITH(nolock)22  WHERE23    a.database_id = DB_ID() AND a.session_id <> @@SPID AND(a.program_name LIKE 'OneIM_Bootstrap%')) THEN24  -125  ELSE 026  END)27END
Open raw exported source
SQL ยท Raw6 lines
1   create   function dbo.QBM_FGIAgentServiceRunning () returns int  as begin return ( select top 1 case  when isnull(HAS_PERMS_BY_NAME('sys.dm_exec_sessions'2, 'Object', 'SELECT'), 0) = 0 then 1 when isnull(HAS_PERMS_BY_NAME(null, null, 'VIEW SERVER STATE'), 0) = 0 then 1 when exists ( select top 1 1  from sys.dm_exec_sessions3 a with (nolock) where a.database_id = DB_ID() and a.session_id <> @@SPID and (a.program_name = 'OneIM_DatabaseAgent'  ) ) then 1 when exists ( select 4top 1 1  from sys.dm_exec_sessions a with (nolock) where a.database_id = DB_ID() and a.session_id <> @@SPID and (a.program_name like 'OneIM_Bootstrap%'5 ) ) then -1 else 0 end ) end 6