Link to home
Start Free TrialLog in
Avatar of JasperIAM
JasperIAMFlag for United States of America

asked on

SQL Query for SMS

I want to run a report in SMS to display PC Name, model, processor, memory, and service tag from Dell.  I found the following SQL query, but it errors out;

SELECT DISTINCT Computer_System_DATA.Name0 'Computer Name',
        Computer_System_DATA.Manufacturer00 'Manufacturer',
        Computer_System_DATA.Model0 'Model',
               processor_data.Name0 'Processor',
        PC_BIOS_DATA.serialNumber00 'Serial Number',
        PC_Memory_DATA.TotalPhysicalMemory0 'Memory'    
FROM Computer_System_DATA
LEFT OUTER JOIN processor_data ON Computer_System_DATA.machineID = processor_data.MachineID
LEFT OUTER JOIN PC_BIOS_DATA ON Computer_System_DATA.machineID = PC_BIOS_DATA.MachineID
LEFT OUTER JOIN PC_Memory_DATA ON Computer_System_DATA.machineID = PC_MEMORY_DATA.MachineID


The error I get after running the report is;

The SELECT permission was denied on the object 'PC_Memory_DATA', database 'ServerName', schema 'dbo'.
Error Number: -2147217911
Source: Microsoft OLE DB Provider for SQL Server
Native Error: 229



I know nothing about SQL, so baby talk would be great.  Also, that query shows Manufacturer and I don't need that and would rather have Username info, so any tips for changing that and fixing error would be appreciated, thanks.
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

>The SELECT permission was denied on the object 'PC_Memory_DATA', database 'ServerName', schema 'dbo'.

that means that the login you use to connect to the database does not have the (select) permission on that table.
you will have to grant some permissions to your login, easiest will be to add the db_datareader role in the database.
Avatar of JasperIAM

ASKER

How do I edit those permissions?  I assume thats in SQL?

Thanks.
> I assume thats in SQL?
you could use a SQL statement for it, or use the sql server management studio's gui.
what do you prefer to use?
Whichever is easier for you to explain.....HA....New territory for me.....SQL newbie....

Thanks.
then, use the GUI.
go to the database for SMS, click on the security -> users folder, and open the properties of the user.
put the checkbox near the db_datareader role, and confirm the change.

after that, your query should not fail due to a select permission problem.
Ok, so I couldn't find the GUI for SQL on my SMS box so I connected to the SQL database from a remote SQL server.  I then went to Security-Logins-MyUsername, properties, then "user mapping", checked db_datareader, hit OK.  I then get this error:

TITLE: Microsoft SQL Server Management Studio
------------------------------

Add member failed for DatabaseRole 'db_datareader'.  (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Add+member+DatabaseRole&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

Cannot use the special principal 'dbo'. (Microsoft SQL Server, Error: 15405)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=15405&LinkId=20476

------


I also found a spot that says my SMS server is running SQL Server Express Edition, if that helps.
that would mean that you try to grant some permissions to the dbo user?
The only user I edited was mine.  Does that indicate my user is dbo user?  If so, what does that mean?  Does that mean i should be able to run the report in SMS?

Once again, I have no clue about SQL...and really just getting into the SMS.

Thanks.
On another note, I can run other reports in SMS.  Its only when I try to create a specific report that it bombs out.
How about another angle?  

Can you edit the following query?  So far, I've been able to edit it so it lists all PC's and not just one, but I would like to drop a few things, and add Service tag info.
 
Please drop User Domain, Computer Domain, Version of OS, and Manufacturer of Processor.  Then, please add Service Tag info, which is "SerialNumber0" from "v_GS_PC_BIOS".  Would like that next to PC Name.
 
I've tried, but I keep blowing it up.
 
Thanks.
 
 
SELECT SYS.Netbios_Name0, SYS.User_Name0, SerialNumber0,  SYS.Resource_Domain_OR_Workgr0,
  OPSYS.Caption0 as C054, OPSYS.Version0,
 MEM.TotalPhysicalMemory0,  IPAddr.IP_Addresses0, Processor.Manufacturer0,
 CSYS.Model0, Processor.Name0, Processor.MaxClockSpeed0  
FROM v_R_System SYS
LEFT JOIN  v_RA_System_IPAddresses IPAddr on SYS.ResourceID = IPAddr.ResourceID
LEFT JOIN  v_GS_X86_PC_MEMORY MEM on SYS.ResourceID = MEM.ResourceID
LEFT JOIN  v_GS_COMPUTER_SYSTEM CSYS on SYS.ResourceID = CSYS.ResourceID
LEFT JOIN  v_GS_PROCESSOR Processor  on Processor.ResourceID = SYS.ResourceID
LEFT JOIN v_GS_OPERATING_SYSTEM OPSYS on SYS.ResourceID=OPSYS.ResourceID
ORDER BY SYS.Netbios_Name0, SYS.Resource_Domain_OR_Workgr0
ASKER CERTIFIED SOLUTION
Avatar of JasperIAM
JasperIAM
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial