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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Invalid Column Name using Aliases

Author  Topic 

lilin8tor
Starting Member

1 Post

Posted - 2006-04-27 : 15:48:41
Hi. When I run the following code I get the errors

Server: Msg 207, Level 16, State 3, Procedure SMB_SB, Line 2
Invalid column name 'SB1'.
Server: Msg 207, Level 16, State 1, Procedure SMB_SB, Line 2
Invalid column name 'SBM1'.

~~~CODE~~~

create view SMB_SB as
select SB.ExternalBatchID as SB1, SB.BatchName as SB2, SB.CreationStationID as SB3,
SB.CreationUserID as SB4, SB.CreationUserName as SB5, SB.BatchClass as SB6,
SB.BatchClassDescription as SB7, SB.TransferID as SB8,

SBM.BatchModuleID as SBM1, SBM.ExternalBatchID as SBM2,
SBM.BatchDescription as SBM3, SBM.ModuleLaunchID as SBM4,
SBM.ModuleCloseUniqueID as SBM5, SBM.ModuleName as SBM6,
SBM.StartDateTime as SBM7, SBM.EndDateTime as SBM8,
SBM.EndDateTime as SBM9, SBM.BatchStatus as SBM10,
SBM.Priority as SBM11, SBM.ExpectedPages as SBM12,
SBM.ExpectedDocs as SBM13, SBM.Deleted as SBM14,
SBM.PagesPerDocument as SBM15, SBM.PagesScanned as SBM16,
SBM.PagesDeleted as SBM17, SBM.DocumentsCreated as SBM18,
SBM.DocumentsDeleted as SBM19, SBM.ChangedFormTypes as SBM20,
SBM.PagesReplaced as SBM21, SBM.ErrorCode as SBM22,
SBM.ErrorText as SBM23, SBM.Orphaned as SBM24,
SBM.TransferID as SBM25

FROM [LFURST_PC\ASCENTCAPTURE].ACSystem.dbo.StatsBatchModule SBM LEFT OUTER JOIN [LFURST_PC\ASCENTCAPTURE].ACSystem.dbo.StatsBatch SB

ON SB.SB1 = SBM.SBM1

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-04-27 : 16:18:42
You can't use column aliases as join criteria (unless the aliases are defined in a derived table)
You need to use the underlying column names in the join criteria.

EDIT:
on SB.ExternalBatchID = SBM.BatchModuleID

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -