I have to make a query in sccm to get all Clients with a specific Software installed. But i have no idea how to get this Job done.
I've tried this on but, it's not accurate enough.
select SMS_G_System_SYSTEM.Name from SMS_R_System inner join SMS_G_System_SYSTEM on SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_SoftwareFile on SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SoftwareFile.FileName = "program.exe" and SMS_G_System_SoftwareFile.FileVersion > "version" and SMS_R_System.Client = 1
I would like to check the programs in the control Panel. I have this tried with this query:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Name not in (select distinct SMS_G_System_COMPUTER_SYSTEM.Name from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "%program%")
But this one gives me no result.
Thanks for the help!
SCCM's built in reporting has a super easy way to see all systems with a particular application installed on them. Would that not work for you?
If you need a query for it, here's an example based on Google Chrome
select SCCM.Name0
,CAT.[ProductName0]
,CAT.[ProductVersion0]
,CAT.[Publisher0]
,CAT.[NormalizedName]</code>
FROM v_GS_INSTALLED_SOFTWARE_CATEGORIZED as CAT
join v_R_System as SCCM on CAT.ResourceID = SCCM.ResourceID
where CAT.[ProductName0] like '%Google Chrome%'
This will return the name of the system, and then a bunch of info about the application.
Related
in SonarQube 4.5 I usually export all violations of a specific project by doing this query:
SELECT
issues.id,
severity as criticality,
IFNULL(rules.name, plugin_rule_key) as name,
message,
projects.name,
projects.kee,
projects.long_name,
line,
rules.plugin_rule_key,
rules.plugin_name
FROM issues
LEFT OUTER JOIN projects ON projects.id = issues.component_id
LEFT OUTER JOIN rules ON rules.id = issues.rule_id
WHERE
issues.status = 'OPEN'
AND projects.enabled = 1
AND issues.root_component_id = XXXXXX
where XXXXXX is the numerical id of the interested project I want to export.
Now we moved to SonarQube 5.6 and the above query no more work.
The database is a bit different from previous version and I tried to modify the query in this way:
SELECT
issues.id,
severity as criticality,
IFNULL(rules.name, plugin_rule_key) as name,
message,
projects.name,
projects.kee,
projects.long_name,
line,
rules.plugin_rule_key,
rules.plugin_name
FROM issues
INNER JOIN projects ON projects.project_uuid = issues.project_uuid
INNER JOIN rules ON rules.id = issues.rule_id
WHERE
issues.status = 'OPEN'
AND projects.enabled = 1
AND projects.root_id = XXXXXX
--AND issues.project_uuid = 'XyzWXyzWXyzWXyzWXyzW'
The query not work and the sql client run out of memory... tried also filtering by issues.project_uuid with the same rusults.
I need this kind of export because I then create an excel sheet with some pivot table and calculation.
What is the correct query for version 5.6?
Thanks in advance.
I've found the correct way to join the issues table with the relative project.
This is now the correct query that works perfectly with SonarQube 5.6 mySql database:
SELECT issues.id,
severity as criticality,
IFNULL(rules.name, plugin_rule_key) as name,
message,
projects.name,
projects.kee,
projects.long_name,
line,
rules.plugin_rule_key,
rules.plugin_name
FROM issues
INNER JOIN projects ON projects.uuid = issues.component_uuid
INNER JOIN rules ON rules.id = issues.rule_id
WHERE issues.status = 'OPEN' AND projects.enabled = 1 AND projects.root_id = XXXXXX;
When using Toad to convert a query featuring outer joins written in the old Oracle notation into ANSI notation, I've run into a problem:
If I write it like this:
select AGENTS.AG_AGCLE, AGENTS.AG_NOM, S01_SERVICES.SE_CODE,
S01_DEPART.DP_CODE, S01_DEPART.DP_NOM, CONGES.CG_CPANT,
S01_PERSO.PE_TEMPSW, MEDWORK.MK_VILLE, MEDWORK.MK_DOCTORNAME
from S01_PERSO,S01_SERVICES,S01_DEPART,AGENTS,CONGES,MEDWORK
where SE_DPCLE=DP_DPCLE
and SE_SECLE=PE_SECLE
and PE_AGCLE=AG_AGCLE
and AG_AGCLE=CG_AGCLE(+)
and AG_MKCLE=MK_MKCLE(+)
and PE_PECLE=25;
Toad converts it to this, which is correct:
SELECT AG_AGCLE, AG_NOM, SE_CODE, DP_CODE, DP_NOM, CG_CPANT, PE_TEMPSW,
MK_VILLE, MK_DOCTORNAME
FROM S01_PERSO
INNER JOIN AGENTS ON (PE_AGCLE = AG_AGCLE)
INNER JOIN S01_SERVICES ON (SE_SECLE = PE_SECLE)
INNER JOIN S01_DEPART ON (SE_DPCLE = DP_DPCLE)
LEFT OUTER JOIN CONGES ON (AG_AGCLE = CG_AGCLE)
LEFT OUTER JOIN MEDWORK ON (AG_MKCLE = MK_MKCLE)
WHERE PE_PECLE = 25;
Whereas if I write it like this, which is the same query (I just wrote one of the join conditions the other way round):
select AGENTS.AG_AGCLE, AGENTS.AG_NOM, S01_SERVICES.SE_CODE,
S01_DEPART.DP_CODE, S01_DEPART.DP_NOM, CONGES.CG_CPANT,
S01_PERSO.PE_TEMPSW, MEDWORK.MK_VILLE, MEDWORK.MK_DOCTORNAME
from S01_PERSO,S01_SERVICES,S01_DEPART,AGENTS,CONGES,MEDWORK
where SE_DPCLE=DP_DPCLE
and SE_SECLE=PE_SECLE
and PE_AGCLE=AG_AGCLE
and CG_AGCLE(+)=AG_AGCLE
and AG_MKCLE=MK_MKCLE(+)
and PE_PECLE=25;
Toad converts it to this:
SELECT AG_AGCLE, AG_NOM, SE_CODE, DP_CODE, DP_NOM, CG_CPANT, PE_TEMPSW,
MK_VILLE, MK_DOCTORNAME
FROM S01_PERSO
INNER JOIN AGENTS ON (PE_AGCLE = AG_AGCLE)
INNER JOIN S01_SERVICES ON (SE_SECLE = PE_SECLE)
INNER JOIN S01_DEPART ON (SE_DPCLE = DP_DPCLE)
LEFT OUTER JOIN MEDWORK ON (AG_MKCLE = MK_MKCLE)
RIGHT OUTER JOIN CONGES ON (CG_AGCLE = AG_AGCLE)
WHERE PE_PECLE = 25;
I have searched online for this problem and found nothing, Has anybody else come across this? Is this a bug, or am I missing something?
I'm using Toad for Oracle Freeware 12.10.0.30, 64 bit on Windows 7 64 bit.
My site generate a lot of queries to database, for each user generates 6 queries. I tried to fine the source of that but my knowlegde was not enough to find. If anyone could help me how to fine the source of that queries?
I used:
Joomla 2.5.8
Main Components: CB, Kunena, SH404SEF, K2, Komento, UddeIM PMS
Main Modules: Gavick News PRO4
Block spam IP
Block bots
The queries which are generate for each user:
SELECT *
FROM `_users`
WHERE `id` = 15
SELECT `g`.`id`,`g`.`title`
FROM `_usergroups` AS g
INNER JOIN `_user_usergroup_map` AS m ON m.group_id = g.id
WHERE `m`.`user_id` = 15
SELECT b.id
FROM _user_usergroup_map AS map
LEFT JOIN _usergroups AS a ON a.id = map.group_id
LEFT JOIN _usergroups AS b ON b.lft <= a.lft
AND b.rgt >= a.rgt
WHERE map.user_id = 15
SELECT a.rules
FROM _assets AS a
WHERE (a.id = 1)
GROUP BY a.id, a.rules, a.lft
SELECT id
FROM _assets
WHERE parent_id = 0
SELECT b.rules
FROM _assets AS a
LEFT JOIN _assets AS b ON b.lft <= a.lft
AND b.rgt >= a.rgt
WHERE (a.id = 1 OR a.parent_id = 0)
GROUP BY b.id, b.rules, b.lft
ORDER BY b.lft
well of course there are going to be a fair amount of queries per use, as you are using extensions such as CB and Kunena, that include queries for each user. Unless you get a message from your host saying too much memory is being used or there is too much traffic, you should be fine.
Joomla is a CMS and therefore these sort of things need to be expected when there are a fair amount of users.
Actually we just fixed a bug in the rules field that was generating an excessive number of queries. It will be fixed in 3.0.4 which is due out next week and whenever another 2.5 release comes out. In the meantime you can fix it yourself.
https://github.com/joomla/joomla-platform/pull/1792
But that's not what you are asking about. The number of queries isn't really the issue (it's totally reasonable) the question is how fast are they.
At my job our main application was written long ago before n-tier was really a thing, ergo - it has tons and tons of business logic begin handled in stored procs and such.
So we have finally decided to bite the bullet and make it not suck so bad. I have been tasked with converting a 900+ line sql script to a .NET exe, which I am doing in C#/Linq. Problem is...for the last 5-6 years at another job, I had been doing Linq exclusively, so my SQL has gotten somewhat rusty, and some of thing I am converting I have never tried to do before in Linq, so I'm hitting some roadblocks.
Anyway, enough whining.
I'm having trouble with the following sql statement, I think due to the fact that he is joining on a temp table and a derived table. Here's the SQL:
insert into #processedBatchesPurgeList
select d.pricebatchdetailid
from pricebatchheader h (nolock)
join pricebatchstatus pbs (nolock) on h.pricebatchstatusid = pbs.pricebatchstatusid
join pricebatchdetail d (nolock) on h.pricebatchheaderid = d.pricebatchheaderid
join
( -- Grab most recent REG.
select
item_key
,store_no
,pricebatchdetailid = max(pricebatchdetailid)
from pricebatchdetail _pbd (nolock)
join pricechgtype pct (nolock) on _pbd.pricechgtypeid = pct.pricechgtypeid
where
lower(rtrim(ltrim(pct.pricechgtypedesc))) = 'reg'
and expired = 0
group by item_key, store_no
) dreg
on d.item_key = dreg.item_key
and d.store_no = dreg.store_no
where
d.pricebatchdetailid < dreg.pricebatchdetailid -- Make sure PBD is not most recent REG.
and h.processeddate < #processedBatchesPurgeDateLimit
and lower(rtrim(ltrim(pbs.pricebatchstatusdesc))) = 'processed' -- Pushed/processed batches only.
So that's raising an overall question first: how to handle temp tables in Linq? This script uses about 10 of them. I currently have them as List. The problem is, if I try to .Join() on one in a query, I get the "Local sequence cannot be used in LINQ to SQL implementations of query operators except the Contains operator." error.
I was able to get the join to the derived table to work using 2 queries, just so a single one wouldn't get nightmarishly long:
var dreg = (from _pbd in db.PriceBatchDetails.Where(pbd => pbd.Expired == false && pbd.PriceChgType.PriceChgTypeDesc.ToLower().Trim() == "reg")
group _pbd by new { _pbd.Item_Key, _pbd.Store_No } into _pbds
select new
{
Item_Key = _pbds.Key.Item_Key,
Store_No = _pbds.Key.Store_No,
PriceBatchDetailID = _pbds.Max(pbdet => pbdet.PriceBatchDetailID)
});
var query = (from h in db.PriceBatchHeaders.Where(pbh => pbh.ProcessedDate < processedBatchesPurgeDateLimit)
join pbs in db.PriceBatchStatus on h.PriceBatchStatusID equals pbs.PriceBatchStatusID
join d in db.PriceBatchDetails on h.PriceBatchHeaderID equals d.PriceBatchHeaderID
join dr in dreg on new { d.Item_Key, d.Store_No } equals new { dr.Item_Key, dr.Store_No }
where d.PriceBatchDetailID < dr.PriceBatchDetailID
&& pbs.PriceBatchStatusDesc.ToLower().Trim() == "processed"
select d.PriceBatchDetailID);
So that query gives the expected results, which I am holding in a List, but then I need to join the results of that query to another one selected from the database, which is leading me back to the aforementioned "Local sequence cannot be used..." error.
That query is this:
insert into #pbhArchiveFullListSaved
select h.pricebatchheaderid
from pricebatchheader h (nolock)
join pricebatchdetail d (nolock)
on h.pricebatchheaderid = d.pricebatchheaderid
join #processedBatchesPurgeList dlist
on d.pricebatchdetailid = dlist.pricebatchdetailid -- PBH list is restricted to PBD purge list rows that have PBH references.
group by h.pricebatchheaderid
The join there on #processedBatchesPurgeList is the problem I am running into.
So uh...help? I have never written SQL like this, and certainly never tried to convert it to Linq.
As pointed out by the comments above, this is no longer being rewritten as Linq.
Was hoping to get a performance improvement along with achieving better SOX compliance, which was the whole reason for the rewrite in the first place.
I'm happy with just satisfying the SOX compliance issues.
Thanks, everyone.
I have the following SQL query:-
select distinct * from dbo.Profiles profiles
left join ProfileSettings pSet on pSet.ProfileKey = profiles.ProfileKey
left join PlatformIdentities pId on pId.ProfileKey = profiles.Profilekey
I need to convert it to a LinqToEntities expression. I have tried the following:-
from profiles in _dbContext.ProfileSet
let leftOuter = (from pSet in _dbContext.ProfileSettingSet
select new
{
pSet.isInternal
}).FirstOrDefault()
select new
{
profiles.ProfileKey,
Internal = leftOuter.isInternal,
profiles.FirstName,
profiles.LastName,
profiles.EmailAddress,
profiles.DateCreated,
profiles.LastLoggedIn,
};
The above query works fine because I haven't considered the third table "PlatformIdentities". Single left outer join works with what I have done above. How do I include PlatformIdentities (the 3rd table) ? I basically want to translate the SQL query I specified at the beginning of this post (which gives me exactly what I need) in to LinqToEntities.
Thanks
Let me know if you want to select something different, but a true join is below
from p in _dbContext.ProfileSet
join ps in _dbContext.ProfileSettings on p.ProfileKey = ps.ProfileKey into a
join pi in _dbContext.PlatformIdentities on p.ProfileKey = pi.ProfileKey into b
select new
{
profiles.ProfileKey,
profiles.FirstName,
profiles.LastName,
profiles.EmailAddress,
profiles.DateCreated,
profiles.LastLoggedIn,
PlatformSettings = a.Select(x=>x),
PlatformIdentities = b.Select(y=>y)
}