Aerodrake
asked on
How do I build an SCCM collection based on a letter in the computer name?
I am trying to create collections based on the machine names.
Lets say the the names are PROSERVD01, PROSERVP01, PROSERVS01
I would like the query to check the letter at the third position from the right (D,P,S) and display only machines that match a certain letter. Any help will be greatly appreciated.
Lets say the the names are PROSERVD01, PROSERVP01, PROSERVS01
I would like the query to check the letter at the third position from the right (D,P,S) and display only machines that match a certain letter. Any help will be greatly appreciated.
ASKER
Thanks for the reply.
I was working with the same idea.. but I'm getting syntax errors. I found this on a unrelated page, do you know if this is true for all WQL?
"Query Syntax is WQL not SQL - some minor syntactical differences. In particular, advanced string manipulations are not supported in WQL (example: Right, Left, Substring, etc.)"
Source: http://securevantage.spaces.live.com/blog/cns!905E136EE69247B4!183.entry
I was working with the same idea.. but I'm getting syntax errors. I found this on a unrelated page, do you know if this is true for all WQL?
"Query Syntax is WQL not SQL - some minor syntactical differences. In particular, advanced string manipulations are not supported in WQL (example: Right, Left, Substring, etc.)"
Source: http://securevantage.spaces.live.com/blog/cns!905E136EE69247B4!183.entry
I'm thought that query strings were sql strings directly issued to the sql server by sccm, but I'm not sure about that. I don't have a sccm server at hand to test it by mysqlf. I can't find any reference to sccm on the page linked by you, though.
However, if you now that the first part of the machine name is constant and equals to PROSERV, the following query should work:
select * from SMS_R_System where Name like "PROSERVS%"
However, if you now that the first part of the machine name is constant and equals to PROSERV, the following query should work:
select * from SMS_R_System where Name like "PROSERVS%"
select SMS_R_SYSTEM.ResourceID,SM S_R_SYSTEM .ResourceT ype,SMS_R_ SYSTEM.Nam e,SMS_R_SY STEM.SMSUn iqueIdenti fier,SMS_R _SYSTEM.Re sourceDoma inORWorkgr oup,SMS_R_ SYSTEM.Cli ent from SMS_R_System where SMS_R_System.NetbiosName like "COMP__NAME%"
Actually, a more decisive answer than what I put above.
select SMS_R_SYSTEM.ResourceID,SM S_R_SYSTEM .ResourceT ype,SMS_R_ SYSTEM.Nam e,SMS_R_SY STEM.SMSUn iqueIdenti fier,SMS_R _SYSTEM.Re sourceDoma inORWorkgr oup,SMS_R_ SYSTEM.Cli ent from SMS_R_System where SMS_R_System.NetbiosName like "PROSERVD%" or SMS_R_System.NetbiosName like "PROSERVP%" or "PROSERVS%"
select SMS_R_SYSTEM.ResourceID,SM
ASKER
The machine names do not all start the same, hence the reason I'm looking for the 3rd letter from the end.
Are they consistent in the number of characters? If so, then use the "_______D%" (7 x "_"). Otherwise, I would recommend using the first Experts comment and morph it with mine using the OR statements.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select * from SMS_R_System where LEFT(RIGHT(Name, 3), 1) = "D"