Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mqh7
Yak Posting Veteran
58 Posts |
Posted - 2012-08-13 : 17:14:15
|
This code works.SELECT DISTINCT a.Name0 AS [Machine Name],b.SiteCode,c.FileVersion AS [smartview.exe],d.Operating_System_Name_and0,c.FilePathFROM v_GS_SoftwareFile c INNER JOINv_GS_SYSTEM a ON c.ResourceID = a.ResourceID INNER JOINv_R_System d ON a.ResourceID = d.ResourceID INNER JOINv_FullCollectionMembership b ON a.ResourceID = b.ResourceIDWHERE (c.FileName = 'smartview.exe') ORDER BY a.Name0----------------------------------------------------------------Ok, so I then wrote this code:select displayname0 AS [Software Title] from v_GS_ADD_REMOVE_PROGRAMSWHERE (displayname0 LIKE '%DameWare%') This too works.-----------------------------------------------------------------So now I want to mimic the code at the top. I want to use a.displayname0. So I wrote this.select a.displayname0 AS [Software Title] from v_GS_ADD_REMOVE_PROGRAMSWHERE (a.displayname0 LIKE '%DameWare%') this fails with this error. Msg 4104, Level 16, State 1, Line 3The multi-part identifier "a.displayname0" could not be bound.Msg 4104, Level 16, State 1, Line 1The multi-part identifier "a.displayname0" could not be bound.-------------------------------------------------------------------I've read the SELECT statement online help but it did not cover this. Why would SELECT DISTINCT a.Name0 AS [Machine Name], work and this fails select a.displayname0 AS [Software Title] ? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-13 : 17:18:07
|
you've not defined a in second case select a.displayname0 AS [Software Title] from v_GS_ADD_REMOVE_PROGRAMS aWHERE (a.displayname0 LIKE '%DameWare%') you can use an alias only after defining it for a table------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-13 : 17:20:34
|
first query already had them defined hence they didnt cause error SELECT DISTINCT a.Name0 AS [Machine Name],b.SiteCode,c.FileVersion AS [smartview.exe],d.Operating_System_Name_and0,c.FilePathFROM v_GS_SoftwareFile c INNER JOINv_GS_SYSTEM a ON c.ResourceID = a.ResourceID INNER JOINv_R_System d ON a.ResourceID = d.ResourceID INNER JOINv_FullCollectionMembership b ON a.ResourceID = b.ResourceIDWHERE (c.FileName = 'smartview.exe') ORDER BY a.Name0 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
mqh7
Yak Posting Veteran
58 Posts |
Posted - 2012-08-13 : 17:33:39
|
Got it...thank you. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-13 : 17:43:46
|
wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|