BEGIN TRAN Add_Customer1
INSERT INTO Customer
(@FirstName, @LastName, @EMail)
SELECT @CustomerID = CustomerID FROM Customer
COMMIT TRAN Add_Customer1
BEGIN TRAN Add_Customer2
INSERT INTO Customer_extra
(CustomerID, CompanyName, Address, City, State, PostalCode, Country)
(@CustomerID, @CompanyName, @Address, @City, @State, @PostalCode, @Country)
COMMIT TRAN Add_Customer2
I get an error that I must declare the variable "CustomerID". If I omit The "GO" in the "BEGIN TRAN Add_Customer1", everything seems OK in SQL. But still I receive an error on the webpage that request the procedure. Someone that can help me with this?
The error was that I used a GO and an EXEC that I shouldn't use. I read a book and they were using Query Analyzer for their code. I wrote it in a stored procedure. That's my mistake. But now, everything works ok. Thanks!