Alex Semibratov started up a blog and has a nice post on how to find the actual OU of a computer. If you have ever looked at the information you will notice you get a lot more than you might be looking for.
I tested this with SMS 2003 and it works since the same view can be used. You will want to replace the “SMS_ENT” with your database name however.
Here is the basic query if you don’t want to create a new view for it:
SELECT A.ResourceID, A.System_OU_Name0
FROM dbo.v_RA_System_SystemOUName AS A INNER JOIN
(SELECT ResourceID, MAX(LEN(System_OU_Name0)) AS len
GROUP BY ResourceID) AS B ON A.ResourceID= B.ResourceID AND LEN(A.System_OU_Name0) = B.len
Here is another query by Casey Robertson that works as well:
SELECT ResourceID, MAX(System_OU_Name0)
GROUP BY ResourceID