如何将表2中的行插入table1 [英] How to insert the row from table 2 to table1

查看:88
本文介绍了如何将表2中的行插入table1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果行的ledgerhead,mainledger,supedger没有在table1上退出,如何将表2中的行插入到表1中。例如



表1

ledgerhead mainledger subledger dr

1资产累积损失 - 1245.00 0.00 1245.00

2资产现金及银行结算现金2141639.00 6245.00

3资产现金及银行结余成本银行4444.00 0.00 4444.00

4资产现金及资产BANK BALANCES GLOBAL IME BANK 12121.00 0.00

5资产收入应收账款15000.00 0.00

6负债储蓄双重存款节省3434.00 0.00 3434.00



表2

ledgerhead mainledger subledger dr

1资产现金及银行结算现金2141639.00 6245.00

2资产现金和银行贷款全球IME银行12121.00 0.00

3资产应收账款应收账款15000.00 0.00

4资产现金和银行结算KIST BANK LTD。 3434.00 0.00 3434.00

5个负债储蓄定期存款2年0.00 12134.00





我要插入table2中的行是第4行和第5行,因为第4,5行的ledgerhead,mainledger和subledger字段与table1行数据不匹配。



请帮帮我...

how to insert the row from table 2 to table 1 if the ledgerhead, mainledger, subledger of the row doesnot exits on table1. eg

table 1
ledgerhead mainledger subledger dr cr
1 ASSETS ACCUMULATED LOSS - 1245.00 0.00 1245.00
2 ASSETS CASH & BANK BALANCES CASH-IN-HAND 2141639.00 6245.00
3 ASSETS CASH & BANK BALANCES COSYS BANK 4444.00 0.00 4444.00
4 ASSETS CASH & BANK BALANCES GLOBAL IME BANK 12121.00 0.00
5 ASSETS RECEIVABLES INTEREST RECEIVABLES 15000.00 0.00
6 LIABILITIES SAVINGS Double Deposit Saving 3434.00 0.00 3434.00

table 2
ledgerhead mainledger subledger dr cr
1 ASSETS CASH & BANK BALANCES CASH-IN-HAND 2141639.00 6245.00
2 ASSETS CASH & BANK BALANCES GLOBAL IME BANK 12121.00 0.00
3 ASSETS RECEIVABLES INTEREST RECEIVABLES 15000.00 0.00
4 ASSETS CASH & BANK BALANCES KIST BANK LTD. 3434.00 0.00 3434.00
5 LIABILITIES SAVINGS Fixed Deposit 2 Year 0.00 12134.00


that i want to insert the row from table2 is row 4 and 5 because the ledgerhead, mainledger and subledger field of row 4,5 doesnot match to table1 rows data.

Please help me ...

推荐答案

INSERT INTO #tempLedgerFinalBalance
                SELECT * FROM #tempLedgerPrevious t2 WHERE
        NOT EXISTS
        (
           SELECT * FROM #tempLedgerFinalBalance as t1 WHERE t1.LedgerHead=t2.LedgerHead AND t1.MainLedger=t2.MainLedger AND t1.SubLedger=t2.SubLedger
        )



工作正常


works fine


这篇关于如何将表2中的行插入table1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆