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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to TSQL - will you debug my query 1

Status
Not open for further replies.

Tomadams

Programmer
Jun 26, 2001
141
US
I have this query below and it is giving me the error msg:
Invalid Column dame 'Retur_Date'. I know it is in the insert statement, but don't know why Here it is:


create table #Merge1 (
[Model_No] [nvarchar] (50) NULL ,
[Return_Date] DateTime,
[QtyRet] int not null default (0),
[QtyPrd] int not null default(0),
[Month_No] int not null default(0)
)

-- get the production data
insert into #Merge1 (
Model_No,
Return_Date,
QtyRet,
QtyPrd,
Month_No
)
select
a.Model_No,
a.Ret_Date,
a.QtyRet,
(
Select
sum([QtyPrd])
From
#Prod1
where
Build_Date <= a.Ret_Date
) as QtyPrd,
a.Month_No
from
#Return1 a
order by
a.Ret_Date


Thanks,
 
It probably means 'Retur_Date' is not a column in the table, hence it's "Invalid".

But I don't see 'Retur_Date' anywhere in your code, so either you pasted the wrong code or typed the error message wrong.
 
Can't see why it should make a difference but have you tried changing Return_date to Ret_Date as it is within #Return1.

Just to see if that solves problem.

Ian

 
I miss typed the error message. It did refer to Return_Date. and I have tried several iterations of Return_Date, Ret-Date, RetDate and get the same message.

No Luck. thanks for the help
 
You don't show us how you build #Prod1 or #Return1, and the problem could be there.

It's very simply that the column does not exist in one of those table's, you just have to backtrack through your code.
 
Thanks Joe for all your help and taking time off from your work.. That was it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top