我正在尝试编写一个将连接两个表并提供所需输出的SP。我首先创建一个临时表,其中列出了两个表的所有字段,然后尝试在表的基础上连接表加入。但它没有帮助我。这是我到目前为止所做的事情
CREATE TABLE #es_jeet
(
[txtype] [CHAR](2) NULL,
[txdesc] [VARCHAR](40) NULL,
[txrefno] [CHAR](25) NULL,
[clntcode] [CHAR](5) NULL,
[polno] [CHAR](10) NULL,
[certno] [CHAR](10) NULL,
[depcode] [DECIMAL](5, 0) NULL,
[deptype] [CHAR](1) NULL,
[namefirst] [CHAR](50) NULL,
[namelast] [CHAR](50) NULL,
[namemid] [CHAR](2) NULL,
[inieffdt] [DATETIME] NULL,
[status] [CHAR](1) NULL,
[chgeffdt] [DATETIME] NULL,
[suboffcode] [CHAR](3) NULL,
[departcd] [CHAR](6) NULL,
[memidno] [CHAR](12) NULL,
[dob] [DATETIME] NULL,
[sex] [CHAR](1) NULL,
[marital] [CHAR](1) NULL,
[occupation] [CHAR](20) NULL,
[empno] [CHAR](10) NULL,
[empdt] [DATETIME] NULL,
[salary] [DECIMAL](13, 2) NULL,
[bankac] [CHAR](40) NULL,
[memnation] [CHAR](3) NULL,
[effdate] [DATETIME] NULL,
[bankcode] [CHAR](4) NULL,
[salarymode] [CHAR](1) NULL,
[bankactype] [CHAR](1) NULL,
[bankaceffdate] [DATETIME] NULL,
[bankacstatus] [CHAR](1) NULL,
[firstcovdt] [DATETIME] NULL,
[maxageexemptind] [CHAR](1) NULL,
[vipstatus] [CHAR](1) NULL,
[sponsoridno] [VARCHAR](20) NULL,
[passportno] [CHAR](15) NULL,
[nationalidno] [CHAR](30) NULL,
[bankname] [CHAR](40) NULL,
[branchname] [CHAR](40) NULL,
[branchaddress] [CHAR](40) NULL,
[bankcurrency] [CHAR](3) NULL,
[swiftcode] [CHAR](15) NULL,
[servicedeskid] [CHAR](10) NULL,
[servicedeskdate] [DATETIME] NULL,
[dmpindicator] [CHAR](1) NULL,
[salarychgeffdt] [DATETIME] NULL,
[studentind] [CHAR](1) NULL,
[outcntyind] [CHAR](1) NULL,
[prodcode] [CHAR](5) NULL,
[benplncd] [CHAR](3) NULL,
[covgcode] [CHAR](5) NULL,
[proposedsa] [DECIMAL](11, 0) NULL,
[prdstatus] [CHAR](1) NULL,
[benid] [CHAR](20) NULL,
[benname] [CHAR](40) NULL,
[benrelat] [CHAR](15) NULL,
[beneffdt] [DATETIME] NULL,
[benshare] [DECIMAL](5, 4) NULL,
[remark] [CHAR](16) NULL,
[rcdsts] [CHAR](1) NULL,
[rcdusrid] [CHAR](20) NULL,
[rcddtstmp] [DATETIME] NULL,
[txstatus] [CHAR](1) NULL,
[uploadusrid] [VARCHAR](20) NULL,
[uploadtime] [DATETIME] NULL,
[errorcode] [CHAR](6) NULL,
[errormsg] [VARCHAR](100) NULL,
[isprocessing] [CHAR](1) NULL,
[SPONSORTYPE] [INT] NULL ,
[GROSSSALARYRANGE][CHAR](1) NULL,
[SALARYBASEDONCOMMISSION][CHAR](3) NULL,
[RESIDINGEMIRATE][CHAR](20) NULL,
[RESIDINGLOCATION][CHAR](20) NULL,
[WORKLOCATIONEMIRATE][CHAR](20) NULL,
[WORKLOCATION][CHAR](20) NULL,
[MEMBERINSURANCEINSIXMONTH][CHAR](50) NULL,
[VISASPONSORID][CHAR](20) NULL,
[SPONSORCONTACTNUMBER][CHAR](50) NULL,
[SPONSOREMAILID][CHAR](50) NULL
)
INSERT INTO #es_jeet
SELECT DISTINCT A.txtype,X.txdesc,txrefno,A.clntcode,A.polno,A.certno,A.depcode,deptype,namefirst,namelast,
namemid,A.inieffdt,A.status,A.chgeffdt,suboffcode,departcd,memidno,dob,sex,marital,occupation,empno,
empdt,salary,A.bankac,memnation,A.effdate,A.bankcode,A.salarymode,bankactype,bankaceffdate,bankacstatus,
firstcovdt,maxageexemptind,vipstatus,sponsoridno,passportno,nationalidno,bankname,branchname,branchaddress,
bankcurrency,swiftcode,servicedeskid,servicedeskdate,dmpindicator,salarychgeffdt,studentind, outcntyind,
PRODCODE =NULL,BENPLNCD =NULL,COVGCODE =NULL,PROPOSEDSA =NULL,PRDSTATUS =NULL,BENID = NULL,BENNAME =NULL,
BENRELAT =NULL,BENEFFDT =NULL,BENSHARE = NULL,REMARK =NULL,A.rcdsts,A.rcdusrid,A.rcddtstmp,txstatus,uploadusrid,
uploadtime,errorcode,errormsg, isprocessing ,TR.SPONSORTYPE,TR.GROSSSALARYRANGE,TR.SALARYBASEDONCOMMISSION,
TR.RESIDINGEMIRATE,TR.RESIDINGLOCATION,TR.WORKLOCATIONEMIRATE,TR.WORKLOCATION,TR.MEMBERINSURANCEINSIXMONTH,
TR.VISASPONSORID,TR.SPONSORCONTACTNUMBER,TR.SPONSOREMAILID
FROM
tmemtrans A (NOLOCK)
INNER JOIN es_txtypes X (NOLOCK)
ON A.txtype = X.txtype
INNER JOIN tpolicy P (NOLOCK)
ON A.polno = P.polno
INNER JOIN tpolpdt TP (nolock)
ON A.polno = tp.polno
INNER JOIN TMEMBERREGULATORYINFO TR (nolock)
ON TR.CLNTCODE = A.CLNTCODE
AND TR.CERTNO = A.CERTNO
AND TR.DEPCODE = A.DEPCODE
WHERE A.rcdsts = 'A'
所以这里#es_jeet是一个临时表,我列出了所有字段,我正在加入这些表来获得结果。请帮助
答案 0 :(得分:1)
,
末尾删除[SPONSOREMAILID][CHAR](50) NULL,
并添加)
,
行uploadtime,errorcode,errormsg, isprocessing ,TR.SPONSORTYPE,TR.GROSSSALARYRANGE,TR.SALARYBASEDONCOMMISSION
醇>