我在SQL SERVER中有两个表,分别是1)tblBuyerCodes
2)tblStatistics
。
我想在SQL Server中实现的是在第一个表中获得一个buyer code
,在该购买者代码的第二个表中获取统计信息,并在第三个表中插入详细信息,我们将其称为tblResults
。如何在SQL Server存储过程中实现这一目标?
规格:
tblBuyerCodes have columns (id, buyercode).
tblStatistics have columns (id,buyercode,goodsbought,total).
tblResults have columns (id, buyercode,goodsbought,total,date).
我要实现的是基于tblBUyerCodes表中获取的购买者代码在tblStatistics中获取结果并将其发布到tblResults中
For example results will be:
row 1: dm6 23 45689
row 2: dm8 45 3456
dm6
和dm8
是买方代码
答案 0 :(得分:0)
基于有限的详细信息,为什么不呢?
INSERT INTO tblResult (id, buyercode,goodsbought,total,date)
SELECT id,
buyercode,
goodsbought,
total,
{SomeDateValue} --Maybe GETDATE()?
FROM tblStatistics;