SQL query to show collection paths and members
Hi guys, I'm after a sql query that will export all the collections along with their path and the members of those collections.
I already have something that will display all the collections and members but it's just a flat list. I'm really after something that will produce something like this:
Collection SystemName
Servers\Prod Server1
Servers\Prod\App1 Server2
Servers\Prod\App1 Server3
Servers\Test Server4
Servers\Dev Server5
Testing\Phase1 Server6
Testing\Phase1\Stage2 Server7
Testing\Phase1\Stage2 Server8
etc
Can this be done?
Hi Garth, appreciate the feedback and I realise the report will probably be ridiculously long, however, the point is irrelevant. Whether it's 100 page or 10,000 pages is not the issue, it's something I've been asked to produce.
Actually I will 100% disagree with you. Your job as the subject matter expert (SME) is to guide people to what they truly want. Blindly giving them something that is useless
is not helping them do their job at all.
I have found that Manager and Management truly appreciate it when you say ”What you are asking for is not what you truly want. You will get a report will 10,000 pages and you
will be over loaded with data.” You then have to follow up and ask “How exactly will know this info help you do your job? What decisions will be made from this report” etc..
this is where you as a SME, will shine and can truly help them do their job.
This report is do able but it is not a 5 minute task. Best of luck with the report.
Garth Jones | My blogs: Enhansoft and
Old Blog site | Twitter:
@GarthMJ
Similar Messages
-
SQL Query to get collections with no members
So I have a query that I'm using to give me collection information (collection ID, collection name, count) but it only shows me collections that have at least 1 member.
This is what I have been using:
SELECT v_Collection.Name ,v_Collection.Comment,v_Collection.CollectionID,COUNT(*) as [Members] FROM v_Collection,v_FullCollectionMembership
where v_Collection.CollectionID=v_FullCollectionMembership.CollectionID
group by v_Collection.Name ,v_Collection.Comment,v_Collection.CollectionID
order by v_Collection.Name
How can I modify the query so it includes collections with no members? We are trying to clean up unnecessary collections.
Thank you!SELECT CollectionID,Name
FROM v_Collection
WHERE MemberCount = 0 -
Can I put a SQL query into a bind variable and then use it to output report
Hi,
Can I put a SQL query into a bind variable and then use it to output report?
I want to create a report and an item "text area" (say P1_TEXT) which can let user to input a SQL query(they are all technical users and knows SQL very well). Then, I use a bind variable (that text area) to store the SQL statement. Then, I add a submit button and I want to use the following to output the report:
select * from (:P1_TEXT);
Do you think it is possible to do that? Any known limitations for APEX in this area?
Thanks a lot,
AngelaYou can, but make sure it's what you really want to do. Make sure you are VERY familiar with SQL Injection. Most people who know what it is, go out of their way to prevent SQL Injection. You're going out of your way to allow it.
You can try using &P1_TEXT. instead of bind variable syntax. Bind variables are one of the best ways to prevent SQL Injection, which is why it's not working for you.
Once again, I strongly urge you to consider the implications of your app, but this suggestion should get it working.
Tyler -
I tried to rename a file, it gave me an error message (can't remember the number - 43??) and then the file disappeared from the original folder. When I do a search, the file comes up under the new name, but it does not show a path, and even though preview shows the contents, I can't open the document (Powerpoint) and I can't move the document. I tried "Copy" and paste but it doesn't work. I tried "Share" with Airdrop and iChat, but the file is inaccessible. When i try to rename the file, it says the filename is too long.
When I try to open it, it says the alias is not good, and asks if I want to fix the alias. I'm afraid to do that and lose all access to this document.
Right now, it feels like a ghost document - it is on the computer intact, but it is in an undisclosed location and inaccessible.
Please help!!I was able to resolve this by repairing permissions, even though no permissions error was listed specifically for that file.
I could also have recovered it through Time Machine, but I'm interested in knowing how not to have this happen again!
I was afraid of rebooting and possibly losing track even of the ghost.
I did not try EasyFind - I'll keep that in mind next time.
Thanks for all the comments. -
Sql query slowness due to rank and columns with null values:
Sql query slowness due to rank and columns with null values:
I have the following table in database with around 10 millions records:
Declaration:
create table PropertyOwners (
[Key] int not null primary key,
PropertyKey int not null,
BoughtDate DateTime,
OwnerKey int null,
GroupKey int null
go
[Key] is primary key and combination of PropertyKey, BoughtDate, OwnerKey and GroupKey is unique.
With the following index:
CREATE NONCLUSTERED INDEX [IX_PropertyOwners] ON [dbo].[PropertyOwners]
[PropertyKey] ASC,
[BoughtDate] DESC,
[OwnerKey] DESC,
[GroupKey] DESC
go
Description of the case:
For single BoughtDate one property can belong to multiple owners or single group, for single record there can either be OwnerKey or GroupKey but not both so one of them will be null for each record. I am trying to retrieve the data from the table using
following query for the OwnerKey. If there are same property rows for owners and group at the same time than the rows having OwnerKey with be preferred, that is why I am using "OwnerKey desc" in Rank function.
declare @ownerKey int = 40000
select PropertyKey, BoughtDate, OwnerKey, GroupKey
from (
select PropertyKey, BoughtDate, OwnerKey, GroupKey,
RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]
from PropertyOwners
) as result
where result.[Rank]=1 and result.[OwnerKey]=@ownerKey
It is taking 2-3 seconds to get the records which is too slow, similar time it is taking as I try to get the records using the GroupKey. But when I tried to get the records for the PropertyKey with the same query, it is executing in 10 milliseconds.
May be the slowness is due to as OwnerKey/GroupKey in the table can be null and sql server in unable to index it. I have also tried to use the Indexed view to pre ranked them but I can't use it in my query as Rank function is not supported in indexed
view.
Please note this table is updated once a day and using Sql Server 2008 R2. Any help will be greatly appreciated.create table #result (PropertyKey int not null, BoughtDate datetime, OwnerKey int null, GroupKey int null, [Rank] int not null)Create index idx ON #result(OwnerKey ,rnk)
insert into #result(PropertyKey, BoughtDate, OwnerKey, GroupKey, [Rank])
select PropertyKey, BoughtDate, OwnerKey, GroupKey,
RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]
from PropertyOwners
go
declare @ownerKey int = 1
select PropertyKey, BoughtDate, OwnerKey, GroupKey
from #result as result
where result.[Rank]=1
and result.[OwnerKey]=@ownerKey
go
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Debugging mode - sql query not showing up in console
Hi,
I have turned on the debugging mode via Admin->Server Configuration->Debug Level. Set it to debug mode.
I restarted the server. I wanted to test if the query will show up if there was an error in the query.
However I am not seeing any query. It complains that there is some error, but doesn't show what query string it is using.
Anyone got any idea how I can get query to show up on console (BI Publisher web interface) as opposed to
going and seeing the log files on the server.
Please let me know.
Thanks
GirijaThankyou Vetsrini.
I will try out custom log table approach.
I see that there is a way to test pl/sql scripts via the DBMS output
and for that we need some invoking program like SQL PLUS to get the
log out into a file.
However, we wanted to see if there is a way to set Pl/SQL log files
and get PL/SQL logs when the calling program is BI Publisher.
regards
Girija -
SQL Query to search for most and least popular brands bought by spesific client and total
Hi to SQL query masters!
I need to create a report on most and least popular brand names within one specific client orders.
For example, during last month or a year among 100% of specific client's orders were 70% IBM products, 20% of HP and 10% Lenovo products.
How do I do that?
And I also think that it might be useful to have a query that shows top popular brands among all sales in given period of time – this statistic might improve warehouse turnover and marketing activities on least popular brand names.
I tried to use info from this link, but it didn’t help https://websmp106.sap-ag.de/~form/sapnet?_SCENARIO=01100035870000000183&_FRAME=OBJECT&_HIER_KEY=701100035871000439554&
Kind regards,
Ilya.Hi
Please Check this
SELECT COUNT (T2.[CardCode]) as 'no of sales', T3.ItmsGrpNam,T2.Cardname
FROM rdr1 T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN ORDR T2 ON T0.DocEntry = T2.DocEntry
INNER JOIN OITB T3 ON T1.ItmsGrpCod = T3.ItmsGrpCod
WHERE T2.[DocDate] >= [%0] and T2.[DocDate] <= [%1]
GROUP BY T3.ItmsGrpNam,T2.Cardname
ORDER BY COUNT (T2.[cardcode]) desc -
SQL Query to show active alerts
Hi, i want to build a ASP page that shows a gridview with the current alerts in scom so we can see them clearly.
What SQL query can get me the current alerts that are showing on Monitoring - Active Alerts, where severity is Critical?
I use System Center 2012 SP1
I checked this post
http://social.technet.microsoft.com/Forums/systemcenter/en-US/898c6f62-9daf-493b-bfd9-193d1f42fc18/sql-query-to-view-current-active-alerts?forum=operationsmanagergeneral
And this page:
http://blogs.technet.com/b/kevinholman/archive/2007/10/18/useful-operations-manager-2007-sql-queries.aspx
But i can't see the correct query.
I don't want to use Powershell as i want to display it properly in a formatted gridview.
ThanksHi,
SELECT * FROM [OperationsManager].[dbo].[AlertView] where Severity = 2 and ResolutionState <> 255 and LanguageCode='ENU'
I want to report on all severity levels, but I'd like to see Warning instead of 1, and Critical instead of 2 and so on. Am I missing a field somewhere?
Jeffrey S. Patton Jeffrey S. Patton Systems Specialist, Enterprise Systems University of Kansas 1001 Sunnyside Ave. Lawrence, KS. 66045 (785) 864-0242 | http://patton-tech.com -
How To Write A Sql Query to Show 0's
I never can remember this :-/ What do I have to do to get a SQL Query to return 0 if the Count of a condition is 0? For example lets say Joe, Jay, Jim could log on, but only Joe & Jim logged in Jay would not be returned in the query below. What
would I need to set-up so that All 3 users would be returned
Select logonName, Count(Logon)
From logonUserInfo
where logonName is not nullGROUP BY logonNameCurrently there is only 1 table involved. I would need a separate table? What would this table need to hold?
You wouldn't need a separate table unless and until you want to store who logged in at what time and so on... then your table structures looks like below..
CREATE TABLE loginnames
loginid INT
name VARCHAR(30),
GO
CREATE TABLE loginTimes
loginid INT,
logintime DATETIME
GO
So, now you can do a left join on both tables on a certain date directly and find out who actually logined and who didn't with a count 0 for the one's who didn't login... and that will abide the principles of normalization as well...
If you don't want to use an another table, you would have to duplicate the loginnames everytime that user logins and also you don't have a track on what date the login happened.. So you will be considering from day 1 to Till date...
Please mark as answer, if this has helped you solve the issue.
Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles. -
SQL Query for full paid invoices and payed out credit notes
Hi alltogether,
I have some problems with a sql query.
I want to export all closed (full paid) invoices and credit notes in a table with the paid date.
The problem is that I have several internal reconciliations for one invoice or credit note.
So with my current query I get all these dates in the result but only for invoices, not for credit notes.
I only need the last internal reconciliation date as payment date for all invoices and credit notes where the open amount is 0.
In SAP B1 the finance team has service invoices and credit notes imported out of an ERP system.
These documents are marked with an 'Y" in the coloumn "U_I_Imported" in the table "OINV" or "ORIN".
SELECT
OINV.DocTotal - OINV.PaidToDate as Offen, OINV.NumAtCard, OINV.U_I_Imported, ORCT.DocDate as 'Zahlungsdatum'
SELECT
OINV.DocTotal - OINV.PaidToDate as Offen, OINV.NumAtCard, OINV.U_I_Imported, ORCT.DocDate as 'Zahlungsdatum'
FROM
OJDT inner join
ORCT on OJDT.BaseRef = ORCT.DocNum inner join
RCT2 on ORCT.DocNum = RCT2.DocNum inner join
OINV on RCT2.BaseAbs = OINV.DocEntry
where
OINV.DocTotal - OINV.PaidToDate = 0 and OINV.U_I_Imported = 'Y'
group by
OINV.NumatCard, OINV.DocTotal - OINV.PaidToDate, OINV.U_I_Imported, ORCT.DocDate
order by
ORCT.DocDate
I hope you can help me.
Kind regards,
MaxThe solution for my problem:
select
OINV.DocTotal - OINV.PaidToDate as 'Offen', OINV.CardCode as 'Kundennummer', OINV.NumAtCard as 'DIAMOD Rechnungsnummer', OINV.DocNum as 'Dokumentennummer', max(ORCT.DocDate) as 'Zahlungsdatum', case when ORCT.DocCurr = (select MainCurncy from OADM) then RCT2.DcntSum else RCT2.DcntSumFC end as 'SkontoRechnungswährung',
RCT2.DcntSum as 'SkontoFirmenwährung'
from
JDT1 inner join
OJDT on JDT1.TransId = OJDT.TransId inner join
ORCT on OJDT.BaseRef = ORCT.DocNum inner join
RCT2 on ORCT.DocNum = RCT2.DocNum inner join
OINV on RCT2.BaseAbs = OINV.DocEntry
where
JDT1.TransType in ('24') and
OINV.U_I_Imported = 'Y' and
OINV.DocTotal - OINV.PaidToDate = 0
group by
OINV.NumAtCard, OINV.DocNum, OINV.CardCode, OINV.DocTotal - OINV.PaidToDate, ORCT.DocCurr, RCT2.DcntSum, RCT2.DcntSumFC
union all
select
OINV.DocTotal - OINV.PaidToDate as Offen, OINV.CardCode as 'Kundennummer', OINV.NumAtCard as 'DIAMOD Rechnungsnummer', OINV.DocNum as 'Dokumentennummer', max(OITR.ReconDate) as 'Zahlungsdatum',
0.0 as 'SkontoRechnungswährung',
0.0 as 'SkontoFirmenwährung'
from
OITR inner join
ITR1 on OITR.ReconNum = ITR1.ReconNum inner join
OINV on ITR1.SrcObjAbs = OINV.DocEntry
where
OINV.DocTotal - OINV.PaidToDate = 0 and ITR1.SrcObjTyp = 13 and OINV.U_I_Imported = 'Y'
group by
OINV.NumatCard, OINV.DocNum, OINV.CardCode, OINV.DocTotal - OINV.PaidToDate
union all
select
ORIN.DocTotal - ORIN.PaidToDate as Offen, ORIN.CardCode as 'Kundennummer', ORIN.NumAtCard as 'DIAMOD Rechnungsnummer', ORIN.DocNum as 'Dokumentennummer', max(OITR.ReconDate) as 'Zahlungsdatum',
0.0 as 'SkontoRechnungswährung',
0.0 as 'SkontoFirmenwährung'
from
OITR inner join
ITR1 on OITR.ReconNum = ITR1.ReconNum inner join
ORIN on ITR1.SrcObjAbs = ORIN.DocEntry
where
ORIN.DocTotal - ORIN.PaidToDate = 0 and ITR1.SrcObjTyp = 14 and ORIN.U_I_Imported = 'Y'
group by
ORIN.NumatCard, ORIN.DocNum, ORIN.CardCode, ORIN.DocTotal - ORIN.PaidToDate -
SCCM 2012 QUERY THAT SHOWS SOFTWARE INSTALLED AND LAST TIME IT WAS USED OR OPENED
Hello
I am in need of an SCCM 2012 query that shows PCs that have Visio , Adobe Professional and Visual Studio and the last time each was used or opened. I have the query below which give me the PC name and the product. Any assistance will be very helpful
select distinct SMS_R_System.NetbiosName, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName from SMS_R_System 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 "%adobe acrobat%pro%"
select distinct SMS_R_System.NetbiosName, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName from SMS_R_System 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 "%visio%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%viewer%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%service pack%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%security
update%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%hydra%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%update%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%MUI%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
not like "%amd%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%microsoft visio%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%vision%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%add-in%"
select distinct SMS_R_System.NetbiosName, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName from SMS_R_System 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
= "Microsoft Visual studio 2012 devenv" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%hotfix%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%security%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
not like "%update%" and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName not like "%service%See me reply to your other post with the exact same details, in the CM07 forum.
http://www.enhansoft.com/ -
[SQL QUERY] Select TCP Port Monitors and their related Watcher Node
Hi everybody,
I'm working on a SSRS report and SQL Query, I have no problem to find all my TCP Port Monitor (SCOM 2012 R2) based on the DisplayName, but I can't figure out how to get their related watcher nodes (in my case only 1 computer is a watcher node).
I can't find which table, which field, contains this information..?
Here is the query i started to write (i select * since i still searching for the right column):
SELECT
FROM StateView s
INNER JOIN BaseManagedEntity me on me.BaseManagedEntityId=s.BaseManagedEntityId
INNER JOIN MonitorView mv on mv.Id=s.MonitorId
INNER JOIN ManagedTypeView mtv on mtv.Id=s.TargetManagedEntityType
--where mv.DisplayName like 'Ping Target Status Check%'
AND me.IsDeleted = '0'
where mv.DisplayName like '%tcpmon%'
and mv.LanguageCode = 'ENU'
--and s.HealthState in (@state)
ORDER BY s.Lastmodified DESC
It would be great if someone can help me !
Thanks,
JulienHi,
After creating a TCP port monitor, we can find a table for this monitor under operationsmanager database :
SELECT *
FROM [OperationsManager].[dbo].[MT_TCPPortCheck_******WatcherComputersGroup]
You will find the warcher computer group.
Regards,
Yan Li
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] -
Should every SQL query have its own event and command?
Hello,
I am developing an application using Cairngorm. My app uses SQL databases.
I'm creating a separate event and command for each SQL query my application requires. I end up with many events and commands - twenty different event/command pairs and I'm not even done yet.
I was wondering if this is the right way to go, or if somehow similar SQL queries should be grouped together in the same event/command, and if so, how would I implement that elegantly?
I've never used Cairngorm before so I want to make sure I do it correctly.
Thank you for your time and any assistance you can offer.From my point of view, writing any SQL query or making queries directly from the presentation layer (eg. flex) to the db server it's almost always incorrect, awfull and maybe even insecure. The client layer should be more independent from the implementation layer as for instance the db server you are using. Instead you should call services on the server side and then they should have a DAO layer o whatever where the queries are done. You could then invoke one of this services and pass parameters that indicates what you want to do. (except you are using remoting where you will be invoking methods directly)
Consider the case where you have a Java implemented service layer, you could be using hibernate to access the database and not writing a single line of SQL (maybe some HQL) and then you could do all the queries you need and return the beans retrieved from the database to the client layer using AMF3 and it's serialization/deserialization mechanisms. In a future you could modify your app to use JPA and then this layer use hibernate, then you client layer will remain the same the only changes will be done under the DAO layer.
So again, in my opinion, db server should never be accesed directly from the presentation layer (Flex, Air or whatever) but from the backend services and this sould be completly abstract to the client layer. I have seen some people trying to do SQL queries from Flash but that it's giving a task to the Flash player it has never been intended to do. A miss use of the thin client the Flash Player is and an bad architecture.
It would be great to hear others opinions. -
Sql query to list menus, submenus and function-names for all resp
Hi,
Please let me know one single sql query to list all the menus, submenus and user-function-names attached for all responsibilities
Thanks...Hi,
See the following threads.
How to find All The Responsibilities with a specific Menu
How to find All The Responsibilities with a specific Menu
SQL query
SQL query
Regards,
Hussein -
SQL query to show "starts with" rather than "is like"
Hi friends,
I've written a query to show all BPs we have sold to in a particular Zip Code region. I have used WHERE T1.[ZipCode] like '%[%0]%' but this brings up everyone where the zip code contains the phrase:
I want to search for Zip Codes starting "BT" it will bring in post codes like MK41 9BT.
How can I tell the report to bring in BPs where the Zip Code starts with "BT"
Thank youHi Tim,
Try this option also ,
WHERE left(T0.[e_mail],2) like '[%0]%%'
OR
WHERE left(T0.[e_mail],2) = '[%0]'
Maybe you are looking for
-
Windows 7 Enterprise is not genuine after installing new hard-drive and cloning the old one
I retired from my job as a university professor two years ago, and they let me keep my laptop computer, which is a Dell Latitude E4300 with Windows 7 Enterprise installed. I do not have any of the original disks for Windows. Recently, the hard-drive
-
Can anyone send me the report of RFQ summary, that displays the following fields in the output list along with the tcodes associated in the report. the output list displays, Purchase Requisition (PR) or Scheduling Agreement that displays lists of a
-
How can I find my offline lost iphone 5?
I think that if you can lock your phone remotely, apple should provide a service where we can turn on our phone remotely. Otherwise, what is icloud find my iphone app good for? I lost my phone a week ago and since I lost it, it has been turned off. I
-
1024 x 768 screens no longer supported?
On screens with width resolution 1024 px, the right column takes up much space. There is often not space enough on the main part of the screen, for code samples and images in the messages to show without vertical scrolling. And the category texts are
-
Illustrator CS6 crashes often when saving files
I'm running Windows 7 64bit I usually have Photoshop CS6, Outlook, Word, Excel open at the same time I have 8GB Ram I haven't found a consistent action that causes the crash. I'll just be working in Illustrator...saving a file or closing a file or l