Tôi có 3 chèn thủ tục lưu trữ mỗi chèn SP dữ liệu trong 2 bảng khác nhauGọi thủ tục lưu trữ từ một thủ tục lưu trữ SQL Server
Table 1 Table 2
idPerson idProduct
name productName
phoneNumber productdescription
FK-idProduct
SP cho bảng 1 SP cho bảng 2
create procedure test1 create procedure test2
WITH WITH
EXECUTE as caller EXECUTE as caller
AS AS
declare declare
@idPerson int, @idProduct int,
@name varchar(20), @productName varchar(50),
@phone varchar(20) @productoDescription varchar(50)
SET nocount on; SET nocount on;
Begin Begin
insert into table1( insert into table2(
idPerson, idProduct,
name, productName,
phone) productDescription)
values( values(
@idPerson, @idProduct,
@name, @productName,
@phone) @productDescription)
end end
tôi cần để gọi kiểm tra thủ tục lưu sẵn 2 từ thử nghiệm thủ tục lưu sẵn 1 và chèn FK-ID vào bảng 1
nó sẽ làm chèn idPerson, tên, điện thoại và idProduct trong table1 và idProduct, productName và productDescription trong bảng 2? –
@@ SCOPE_IDENTITY không phải là một điều. Sử dụng SCOPE_IDENTITY() – MPaul