Author |
Topic |
tracy5436
Yak Posting Veteran
50 Posts |
Posted - 2009-04-24 : 18:06:07
|
I have a table which I would like to merge the values in. I have created a temp table and extracted the merged data. I would then like to insert the data from the temp table into the original table. This is my query :SELECT itemnmbr as itemnmbr1, lotnumbr as lotnmbr1, min(daterecd) as receiptdate1,sum(qtyrecvd) as qtyrecvd1,IDENTITY(smallint, 1, 1) as dex_row_id1, locncode as locncode1,sum(qtysold) as qtysold1into #lotFROM iv00300group by itemnmbr,lotnumbr, locncodedelete iv00300insert into iv00300 (itemnmbr, lotnumbr, receiptdate,qtyrecvd,dex_row_id,locncode,qtysold) values (itemnmbr1, lotnumbr1, receiptdate1,qtyrecvd1,dex_row_id1,locncode1,qtysold1)from #lotdrop table #lotWhen I run it, I get the message :"Server: Msg 128, Level 15, State 1, Line 25The name 'itemnmbr1' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted."How do I fix this ? |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-04-24 : 18:09:35
|
insert into iv00300 (itemnmbr, lotnumbr, receiptdate,qtyrecvd,dex_row_id,locncode,qtysold) select itemnmbr1, lotnumbr1, receiptdate1,qtyrecvd1,dex_row_id1,locncode1,qtysold1from #lot |
|
|
|
|
|