adamas Posted August 30, 2022 at 01:54 PM Report Share #627035 Posted August 30, 2022 at 01:54 PM Boa tarde, Utilizo o PHC v30 Local e gostaria de fazer uma query de modo a obter um dashboard com as licenças consumidas, e assim saber rapidamente a informação sem ter de ir a Sistema>Status Geral> Proteção> Monitor de consulta de licenças consumidas. Alguém me sabe indicar qual é a tabela que devo consultar? Obrigada Link to comment Share on other sites More sharing options...
Bernardo Ribeiro Posted September 5, 2022 at 10:40 AM Report Share #627116 Posted September 5, 2022 at 10:40 AM Bom dia, Aqui vai, DECLARE @sql NVARCHAR(MAX) SET @sql= N'' IF OBJECT_ID('tempdb..#packlist') IS NOT NULL DROP TABLE #packlist CREATE TABLE #packlist ( nomepack VARCHAR(254) ,cs_spid INT ,vfp_pid BIGINT ,phc_user varchar(250) ,phc_key varchar(250) ) SELECT @sql = @sql + CASE WHEN t.nCount = 1 THEN '' ELSE ' union all ' END + ' select nomepack COLLATE Latin1_General_CI_AI as nomepack, cs_spid, vfp_pid, phc_user COLLATE Latin1_General_CI_AI as phc_user, phc_key COLLATE Latin1_General_CI_AI as phc_key from ' + t.nometab FROM ( SELECT temp.name as nometab ,ROW_NUMBER() OVER (ORDER BY temp.name) nCount FROM tempdb.sys.objects temp WHERE temp.name like '##PHC26CS%' ) t INSERT #packlist EXEC sp_executesql @sql SELECT pklist.nomepack COLLATE Latin1_General_CI_AI as nomepack ,pklist.phc_user COLLATE Latin1_General_CI_AI as phc_user ,t2.session_id ,t2.host_process_id ,t2.host_name COLLATE Latin1_General_CI_AI as host_name ,t2.bd ,t2.connect_time , 0 lics ,pklist.phc_key COLLATE Latin1_General_CI_AI as phc_key FROM #packlist as pklist INNER JOIN ( SELECT DISTINCT s.host_name COLLATE Latin1_General_CI_AI as host_name ,s.host_process_id ,c.client_net_address ,c.session_id -- db_name(s.database_id) as bd, ,db_name(p.dbid) as BD ,c.connect_time FROM sys.dm_exec_connections AS c INNER JOIN sys.dm_exec_sessions AS s ON c.session_id = s.session_id INNER JOIN sys.sysprocesses as p ON s.session_id = p.spid ) t2 ON t2.host_process_id = pklist.vfp_pid and t2.session_id = pklist.cs_spid ORDER BY nomepack 1 Report Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now