Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple join

Status
Not open for further replies.

LesStockton

Programmer
Mar 29, 2005
20
US
What's wrong with the join in this stored procedure I'm trying to write?

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[udCount_OrdersNew]
@OrderOwnerCompany int
AS
SELECT
Count(OrderID) AS Count
FROM [T_Order O] JOIN [T_OrderStatus OS]
WHERE O.OwnerCompany = @OrderOwnerCompany
AND O.ReviewedInd = 0
AND OS.Description='New'

 
remove the alias from the []. It thinks they names of the tables are T_Order O and T_OrderStatus OS
Also you don't need the []s/

FROM T_Order O Join T_OrderStatus OS

Jim
 
where is your join condition??????
Code:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[udCount_OrdersNew]
    @OrderOwnerCompany int
AS
SELECT 
    Count(OrderID) AS Count
FROM T_Order O JOIN T_OrderStatus OS 
on o.OwnerCompany  =os.OwnerCompany  -- is this the correct join??
WHERE O.OwnerCompany = @OrderOwnerCompany
     AND O.ReviewedInd = 0
     AND OS.Description='New'

Denis The SQL Menace
SQL blog:
Personal Blog:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top