2016-11-25 108 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'