SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how do I replace @prompt with a list of PC's?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mqh7
Yak Posting Veteran

58 Posts

Posted - 08/06/2012 :  18:19:21  Show Profile  Reply with Quote
someone had written this code on our sccm server (under reports)

select v_R_System.Netbios_Name0, v_GS_PC_BIOS.Manufacturer0, v_GS_PC_BIOS.SerialNumber0,v_GS_COMPUTER_SYSTEM.Model0
FROM v_R_System JOIN v_GS_PC_BIOS on v_R_System.ResourceID = v_GS_PC_BIOS.ResourceID JOIN v_GS_COMPUTER_SYSTEM on v_R_System.ResourceID = v_GS_COMPUTER_SYSTEM.ResourceID
Where v_GS_PC_BIOS.SerialNumber0 = @serial

So you enter a serial number and it returns the computer name for that serial number. fun stuff.


but I have a list of about 800 machines so I don't want to run this report over 800 times. how would I modify this code so instead of a @Prompt I can just enter in a list of 800 computer names?

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 08/06/2012 :  18:25:02  Show Profile  Reply with Quote
change

v_GS_PC_BIOS.SerialNumber0 = @serial

to

v_GS_PC_BIOS.SerialNumber0 in ( query to get 800 machine ids here)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mqh7
Yak Posting Veteran

58 Posts

Posted - 08/06/2012 :  18:31:19  Show Profile  Reply with Quote
thank you but that gives me a syntax error. Incorrect Syntax near: v_GS-PC_BIOS
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 08/06/2012 :  18:33:19  Show Profile  Reply with Quote
show your query


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mqh7
Yak Posting Veteran

58 Posts

Posted - 08/06/2012 :  18:45:28  Show Profile  Reply with Quote
select v_R_System.Netbios_Name0, v_GS_PC_BIOS.Manufacturer0, v_GS_PC_BIOS.SerialNumber0,v_GS_COMPUTER_SYSTEM.Model0
FROM v_R_System JOIN v_GS_PC_BIOS on v_R_System.ResourceID = v_GS_PC_BIOS.ResourceID JOIN v_GS_COMPUTER_SYSTEM on v_R_System.ResourceID = v_GS_COMPUTER_SYSTEM.ResourceID

v_GS_PC_BIOS.SerialNumber0 in
(
'MXL71205PR',
'2UA7400P83',
'MXL70403JN'
)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 08/06/2012 :  19:09:20  Show Profile  Reply with Quote
quote:
Originally posted by mqh7

select v_R_System.Netbios_Name0, v_GS_PC_BIOS.Manufacturer0, v_GS_PC_BIOS.SerialNumber0,v_GS_COMPUTER_SYSTEM.Model0
FROM v_R_System JOIN v_GS_PC_BIOS on v_R_System.ResourceID = v_GS_PC_BIOS.ResourceID JOIN v_GS_COMPUTER_SYSTEM on v_R_System.ResourceID = v_GS_COMPUTER_SYSTEM.ResourceID
WHERE
v_GS_PC_BIOS.SerialNumber0 in
(
'MXL71205PR',
'2UA7400P83',
'MXL70403JN'
)



you missed a WHERE

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mqh7
Yak Posting Veteran

58 Posts

Posted - 08/07/2012 :  09:38:09  Show Profile  Reply with Quote
That worked!! Awesome, thank you :-)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 08/07/2012 :  09:47:31  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000