Sending Direct Query to DB question

Sending Direct Query to DB question

Hi, sorry but I did not really know where the best place for this topic would be.

I am attempting to directly query the Altiris database to determine what computers a licensed piece of software is installed on.

I know that there are at least 40 results to the query and that the top result is BH-206-01. If I go into the management console and create a new report and directly enter the SQL I am trying to use, it works with no problem.

When I try to run it using php, I get this output: http://fcsd-isc2.fcsd.monroe.edu/license/test.php

The "Row Value" is my own doing... As you can see, I get some crazy results.

Does anyone know what might be causing this problem? If no one knows, does anyone know anywhere else I could ask?

Thank you in advance.

I thought it might be

I thought it might be helpful to include the sql query:

SET ROWCOUNT 0

if(cast('".$licenseGUID."' as uniqueidentifier) <> 0x0)

begin
    if(object_id('tempdb..#Resources')is not null)
    begin
      drop table #Resources
    end

    begin
      create table #Resources
      {
         _ResourceGuid uniqueidentifier primary key clustered
      }
     end

     insert #Resources
     exec spCon_SoftwareLicenseRun Operation '".$licenseGUID."', 100, 'en-US'
     
     select cast('".$licenseGUID."' as uniqueidentifier) as '_LicenseGuid', _ResourceGuid as '_ComputerGuid', Item.Name
     from
        #Resources
        inner join vActiveAsset aa on
           #Resources._ResourceGuid = aa.Guid
        inner join Item on
           Item.Guid=aa.Guid
        order by Item.Name

      if(object_id('tempdb..#Resources') is not null)
      begin
        drop table #Resources
      end
   end
   else
   begin
      Select top 0 '' as [No Results]
  end

I took this query directly from another altiris report. the $licenseGUID is the passed value from another function.