从两个表中查找并将重复的行插入到临时表中 [英] Find And Insert Duplicate Rows Into Temp Table from Two Tables

查看:104
本文介绍了从两个表中查找并将重复的行插入到临时表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我在两个表和
中找到重复的行 插入到temptable

当我使用此查询搜索重复的行时,它成功地给了我结果.
如我所愿,
======

Hi All

I am finding the duplicates rows from two tables and
inserting into temptable

When i used this query to search duplicate rows its giving me result successfully.
as i want ,
======

SELECT * FROM
TrnBal , ullr
WHERE TrnBal.LR_no = ullr.LR_No


=======

但是,当尝试将相同的结果插入到temptable中时,它给了我错误.

这是我的第二个查询,

===


=======

But when try to insert the same result into temptable its giving me error.

here is my second query ,

===

Insert into duprow (LR_No,Lr_Date ,Bkg_Stn ,FrmShort ,Dst,ToShort,Consignor_Name,
Consignee_Name ,Pvt_Mark ,Discription ,Article,Weight,Value ,Pmt_Mode ,DoorDel, LR_Remark, Freight ,BC ,Handling ,DDel , LC ,Others ,S_Tax ,Amount ,Initial ,Truck_No , Report_No, Rep_Date ,Trk_From , Trk_To  , Arv_No ,Arv_Date ,L_Stat)
Select LR_No,Lr_Date ,Bkg_Stn ,FrmShort ,Dst ,ToShort ,Consignor_Name,
Consignee_Name ,Pvt_Mark, Discription ,Article,Weight,Value ,Pmt_Mode ,DoorDel ,LR_Remark, Freight ,BC ,Handling ,DDel , LC ,Others ,S_Tax ,Amount ,Initial ,Truck_No ,Report_No ,
Rep_Date ,Trk_From , Trk_To  , Arv_No ,Arv_Date ,L_Stat
FROM TrnBal,ullr
Where TrnBal.LR_No = ullr.LR_No


=============

错误:
消息209,第16级,状态1,第4行
列名称不明确,称为"LR_No".
消息209,第16级,状态1,第4行
列名称不明确,称为"Lr_Date".
消息209,第16级,状态1,第4行
列名称不明确''Bkg_Stn''.
消息209,第16级,状态1,第4行
列名称不明确,为"FrmShort".
消息209,第16级,状态1,第4行
列名称不明确,称为"Dst".
消息209,第16级,状态1,第4行
列名称不明确,为"ToShort".
消息209,第16级,状态1,第4行
列名含糊不清的"Consignor_Name" ....... more ....具有所有字段.

伙计们,我陷入困境,请帮助我,
任何帮助将不胜感激..

等待您的回复....????
在此先感谢.


==============

ERROR :
Msg 209, Level 16, State 1, Line 4
Ambiguous column name ''LR_No''.
Msg 209, Level 16, State 1, Line 4
Ambiguous column name ''Lr_Date''.
Msg 209, Level 16, State 1, Line 4
Ambiguous column name ''Bkg_Stn''.
Msg 209, Level 16, State 1, Line 4
Ambiguous column name ''FrmShort''.
Msg 209, Level 16, State 1, Line 4
Ambiguous column name ''Dst''.
Msg 209, Level 16, State 1, Line 4
Ambiguous column name ''ToShort''.
Msg 209, Level 16, State 1, Line 4
Ambiguous column name ''Consignor_Name''.......more.... with all field.

Guys i am stuck in Please help me ,
Any Help will be highly appreciated..

Waiting for your reply....????
Thanks in Advance.

推荐答案

LR_NoLr_Date 等.可能同时存在于两个表中,并且您正在编写

FROM TrnBal,ullr

Select语句中,将导致上述错误.

因此,为两个表中的columns 指定Table ,例如

Select TrnBal.LR_No, TrnBal.Lr_Date
The columns LR_No, Lr_Date etc. may be present in both the tables and you are writing

FROM TrnBal,ullr

in the Select statement, which gives rise to the above error.

So specify the Table for the columns which are present in both tables, say

Select TrnBal.LR_No, TrnBal.Lr_Date


这篇关于从两个表中查找并将重复的行插入到临时表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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