如何创建要插入两个表的SP? [英] How to create a SP to insert into two tables ?
本文介绍了如何创建要插入两个表的SP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我目前正在学习T-SQL,但是我似乎找不到如何创建存储过程的方法,我正在尝试
Hi
I''m currently learning T-SQL but I cant seem to find how create a store procedure, Im trying to
INSERT INTO ProductTable ( ProductID , ProductName , ProductColor , ProductPrice , ProductMarkUp)
VAlUES( @ProductID, @ProductName, @ProductName, @ProductColor, @PRoductPrice, @ProductMarkUp)
SET @ProductID = ProductDetailsID
BEGIN
INSERT INTO ProductDetails (SupplierName, SupplierCountry, Quantity, UnitSold, CostPrice, ProductDetailsID)
VALUES(@SupplierName, @SupplierCountry, @Quantity, @UnitSold, @CostPrice , @ProductDetailsID)
我如何才能轻松实现这一目标.谢谢您
How cant I altenatively acheive this.Thank you
推荐答案
Create Proc InsertIntoMultipleTables
(
@Parameter1 Type,
@Parameter2 Type,
@Parameter3 Type
)
AS
Begin
insert into table1 (Col1, Col2) values (@Parameter1, @Parameter2)
insert into table2 (Col1, Col2) values (@Parameter1, @Parameter3)
End
享受...
Nitin Verma
Enjoy...
Nitin Verma
此 [
This[^] will help you to get started.
这篇关于如何创建要插入两个表的SP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文