2016-11-25 191 views
0

這是我的查詢怎麼辦時,註釋行是什麼,我想插入SQL SERVER插入使用插入多行到選擇語句

insert into tbl_StockTransactions(ItemCode,TransactionDate,Narration,Docid,ReferenceNo,Qty,Price,UserId,BranchCode,StaffCode) select ItemCode,getDate(),Description,PostingDocid,'New Ref',Qty,Price,'uid','bc','sc' from tbl_PostingDetailsStock where PostingReference='A000275' 
--select ItemCode,getDate(),Description,PostingDocid,'New Ref',Qty,Price,'uid','bc','sc' from tbl_PostingDetailsStock where PostingReference='A000276'; 

回答

3

試試這個代碼:

insert into tbl_StockTransactions(
    ItemCode, TransactionDate, Narration, Docid, ReferenceNo, Qty, 
    Price, UserId, BranchCode, StaffCode 
) 

SELECT ItemCode, getDate(), Description, PostingDocid, 'New Ref', Qty, 
    Price, 'uid', 'bc', 'sc' 
FROM tbl_PostingDetailsStock 
WHERE PostingReference IN ('A000275','A000276') 
+0

對不起,這是我想要的人 –

+0

@EmmanuelOgoma,接受答案。 – PawelCz

+1

@EmmanuelOgoma,是否符合您的要求,請點擊選中標記下面只是給予好評按鈕[旗它作爲接受]這個答案..在將來使用 – Vikrant

0
insert into tbl_StockTransactions(ItemCode,TransactionDate,Narration 
,Docid,ReferenceNo,Qty,Price,UserId,BranchCode,StaffCode) 
select ItemCode,getDate(),Description,PostingDocid,'New Ref',Qty,Price,'uid','bc','sc' from tbl_PostingDetailsStock 
where PostingReference IN ('A000275','A000276') 
0
select ItemCode,getDate(),Description,PostingDocid,'New Ref',Qty,Price,'uid','bc','sc' 
into tbl_StockTransactions 
from tbl_PostingDetailsStock 
where PostingReference='A000275'