Hello everyone, I am trying to change a procedure that I created to insert a new book into three tables. The table has autoencrement in the book_id column, and tables B and C are not null, I am using @@ IDENTITY to get the last value of table_id of table A but when trying to insert a table it says that table_id column of table C can not accept null value, I believe that for table C @@ IDENTITY does not take the last value from the previous table could someone help me? and please excuse me if it's a little confusing I'm new here and I do not know how to separate the code from the text.
ALTER PROCEDURE adicionarNovoLivro(
@nome_livro varchar(255),
@nome_autor varchar(255),
@ano_livro int,
@nome_editora varchar(100),
@preco_livro float
)
AS
BEGIN
INSERT INTO tbl_LivrosA VALUES(@nome_livro, @nome_autor, @ano_livro, @nome_editora, @preco_livro)
INSERT INTO tbl_LivrosB VALUES(@@IDENTITY, @nome_livro, @nome_autor, @ano_livro, @nome_editora, @preco_livro)
INSERT INTO tbl_LivrosC VALUES(@@IDENTITY, @nome_livro, @nome_autor, @ano_livro, @nome_editora, @preco_livro)
END
EXEC adicionarNovoLivro 'Nome na Taverna', 'Álvarez de Azevedo', 1855, 'Editora Abril', 16.96