One idea you can do.. I frequently look at a query in the View (create a view and don't save it when completed) portion of SQL Enterprise Manager to "test" queries to insure they work and I have the syntax correct. When I get everything right, then I can paste the results into the program/app I need it in.
One other thing with your Name or MacAddress, either and/or both are going to be unique. Why do you need both in your query? That is, you can only have one computer with a name of xyz on the domain, correct? Also, the MAC Address will always be unique as well. So, why do you need both? I would most likely choose the one that is probably the easiest to work with like:
Code:
$queryForCID="SELECT TOP 1 cid FROM computers WHERE Name='"+@wksta+"'"
Note: I put the @Wksta macro outside the quotes for the SQL Statment.
To take this a step further, I created a view on my SQL Box and here is what I get:
Code:
SELECT TOP 1 id FROM dbo.Computers WHERE (pcname='NAME')
And it works great.
HTH,
Kent