Query Question

Hi everyone,

I have the following query

select SMS_R_System.NetbiosName, SMS_R_System.LastLogonUserName

from  SMS_R_System

where SMS_R_System.LastLogonUserName like ##PRM:SMS_R_System.LastLogonUserName##

It asks for a username and returns the PC name associated with it. My question is how do I modify the query to place wild characters ahead and behind the inputted text?

Example: Right now I have to know the exact user name or enter %portionofusername%

It is my desire to place the % wildcard characters concantenated to the input so that I only have to know a small portion of the username.

Thanks!!!


November 27th, 2012 8:57pm

It would be better to use the reporting services point as SQL provides more possibilities compared to WQL (which is used in queries).
Free Windows Admin Tool Kit Click here and download it now
November 27th, 2012 9:16pm

We are unable to use the reporting services because the people hosting our SCCM environment have locked it down for some reason.
November 27th, 2012 9:40pm

I have just tested your Query and have no problems using % or _ to replace any portion of the user name.

Free Windows Admin Tool Kit Click here and download it now
November 28th, 2012 9:52am

I know that it works if you manually enter it. I want to hardcode it into the query so that the user can just enter a small portion of the username. It is my belief that I need to concantenate the % wildcard characters to the ##PRM:SMS_R_System.LastLogonUserName## but I don't know how to do it.

select SMS_R_System.NetbiosName, SMS_R_System.LastLogonUserName

from  SMS_R_System

where SMS_R_System.LastLogonUserName like ##PRM:SMS_R_System.LastLogonUserName##

November 29th, 2012 2:55pm

Yes, I know this is an old post, but Im trying to clean them up. Did you solve this problem, if so what was the solution? Give this a try.

select SMS_R_System.Name from  SMS_R_System where SMS_R_System.LastLogonUserName = ##PRM:SMS_R_System.LastLogonUserName## order by SMS_R_System.Name

Free Windows Admin Tool Kit Click here and download it now
February 3rd, 2015 7:36pm

Nope, that doesn't work either. That actually takes away the functionality of the wildcards. We eventually had our users imported into SCCM from active directory and can search them there. This isn't really an issue anymore. Thanks for trying!
July 1st, 2015 5:37pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics