Sql server 销售信息聚合

Sql server 销售信息聚合,sql-server,tsql,Sql Server,Tsql,我有一个场景,在这个场景中,我在一个表中获得了销售信息,非常像这样: SalesTable ID,ID\u Transct,客户,产品,日期 我想把这些销售额放在另一个表格中,包括: DeliveryTable ID\u Del,客户,日期 DeliveryDeTable ID、ID\u Del、产品等 我想在SQL Server中使用一个存储过程来实现这一点,该存储过程将为参数ID\u Transct提供一个ID\u Transact可以有许多客户机和产品 有人知道吗?提前谢谢 另外,我对T-

我有一个场景,在这个场景中,我在一个表中获得了销售信息,非常像这样:

SalesTable ID,ID\u Transct,客户,产品,日期

我想把这些销售额放在另一个表格中,包括:

DeliveryTable ID\u Del,客户,日期

DeliveryDeTable ID、ID\u Del、产品等

我想在SQL Server中使用一个存储过程来实现这一点,该存储过程将为参数ID\u Transct提供一个ID\u Transact可以有许多客户机和产品

有人知道吗?提前谢谢


另外,我对T-SQL的理解一般

我可以用C/VB.NET来实现,但我的老板希望它在SQL方面,老实说,我没有任何T-SQL的经验来实现这样一个存储过程,我现在正在尝试学习T-SQL,但我很急着要做这个。你需要两个insert语句。一个用于DeliveryTable,一个用于DeliveryDetTable。是的,问题是如何确定ID_Del列它在DeliveryTablescope_Identity上是否为Identity?是的,但问题是我的T-SQl和SQl在一般知识中是如此基础。
create procedure [dbo].[Sp_Test]
@ID_Transact int

As 
begin

insert into Table_2 (Date, Client)
select distinct Date, Client from Table_1 
where ID_Vente = @ID_Transact


insert into Table_2Det (ID_Del, Produit )
select Table_2 .ID_Del , Table_1 .Produit  from Table_1 inner join Table_2 on Table_1 .Client = Table_2 .Client 


end
GO