如何更新行如果存在A,B,Tarih和Not exists如何插入?如何添加或更新臨時表中的新值?
我原來的代碼:
Insert X(A,B,C,D,E,Tarih)
select substring(dosya,2,25) as A,
substring(dosya,27,15) as B,
substring(dosya,70,40) as C,
CONVERT(DECIMAL(17,2),substring(dosya,52,17)) as D,
case when substring(dosya,124,2)='00' then 'TL'
when substring(dosya,124,2)='01' then 'USD'
when substring(dosya,124,2)='02' then 'CHF'
when substring(dosya,124,2)='03' then 'CAD'
when substring(dosya,124,2)='04' then 'KWD'
when substring(dosya,124,2)='05' then 'GBP'
when substring(dosya,124,2)='06' then 'SAR'
when substring(dosya,124,2)='07' then 'JPY'
when substring(dosya,124,2)='08' then 'EUR'
when substring(dosya,124,2)='09' then 'AUD'
when substring(dosya,124,2)='10' then 'IRR'
when substring(dosya,124,2)='11' then 'DK'
when substring(dosya,124,2)='12' then 'SEK'
else 'Döviz' end as E,
@tarih as Tarih
from #TempLog
我想更新現有價值
僞代碼:
if exist (A,B,C in BankaEntegrasyonLog)
{
Update Row!
}
else
{
Insert
X(A,B,C,D,E,Tarih)
select substring(dosya,2,25) as . . . . .
}
您需要'merge'命令。我建議你在SQL Server文檔中查找它。 –