
November 28th, 2012, 11:26 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 2
Time spent in forums: 12 m 58 sec
Reputation Power: 0
|
|
|
Update using a subquery
I have this SQL
Code:
select zero.ftr_dbtc, zero.ftr_tref,
(select [InvoiceNumber] from [InterfaceLive].[dbo].[SITS_FeesImport] datlines where
zero.ftr_pstd=datlines.ftr_pstd and left(zero.ftr_scjc,7)= datlines.[ftr_dbtc]) as invoicenumber
from SITS_FeesImport_ZeroInv zero where BursaryType='Textline'
it uses two tables, I use values in feesimport_zeroinv table to get the value of invoicenumber from the feesimport table
It works but what I really want to do is update the invoicenumber in feesimport_zeroinv but I can't get it to work
Something like this (this doesn't work)
Code:
update SITS_FeesImport_ZeroInv zero
set [InvoiceNumber]= (select [InvoiceNumber] from [InterfaceLive].[dbo].[SITS_FeesImport] datlines where zero.ftr_pstd=datlines.ftr_pstd and left(zero.ftr_scjc,7)= datlines.[ftr_dbtc])
where BursaryType='Textline'
Any help most appreciated
M
|