1
我想從上載文件批量插入到新表中,但我也想從其他表中使用左連接插入數據,你能檢查我的查詢出了什麼問題嗎?SQL Server批量插入左連接
INSERT INTO gen048_ACCNUMS (accnum)
SELECT DISTINCT REPLACE(dbo.fn_Parsename(WHOLEROW,'|',10), CHAR(9), '')
FROM #temp1
set @sql = '
INSERT INTO '[email protected]+' (ftype, ccode, refdate, dupload, accname, add1, add2, zip, add3, add4, add5, accdate, book, solcode)
SELECT
''GEN048'',
'''',
('[email protected]+'),
(SELECT CONVERT(VARCHAR(12),GETDATE(), 101)),
dbo.fn_Parsename(WHOLEROW,''|'',0),
dbo.fn_Parsename(WHOLEROW,''|'',1),
dbo.fn_Parsename(WHOLEROW,''|'',2),
dbo.fn_Parsename(WHOLEROW,''|'',3),
dbo.fn_Parsename(WHOLEROW,''|'',4),
dbo.fn_Parsename(WHOLEROW,''|'',5),
dbo.fn_Parsename(WHOLEROW,''|'',6),
dbo.fn_Parsename(WHOLEROW,''|'',7),
(select substring(dbo.fn_Parsename(WHOLEROW,''|'',8), 1, 1)),
(select substring(dbo.fn_Parsename(WHOLEROW,''|'',8), 1, 3)),
(SELECT branch
FROM '[email protected]+'
LEFT JOIN BRANCH_LIST ON '[email protected]+'.solcode = BRANCH_LIST.solcode)
FROM #temp1'
print @sql
exec (@sql)
SELECT 'File has been successfully uploaded', @fileDate,'success' as msg
END
這是SQL消息
FROM#temp1中 子查詢返回大於1倍的值。當子查詢遵循=,!=,<,< =,>,> =或當子查詢用作表達式時,這是不允許的。
它會產生錯誤嗎?它做錯了什麼? –
你還可以發佈'print @ sql'的輸出嗎? – Squirrel
沒有告訴我們確切的問題/錯誤信息,我們很難幫助你。 – Greg