CREATE PROC [dbo].[spInsertOrder]
@OrderID INT OUTPUT
INSERT INTO dbo.Orders
SELECT @OrderID = @@IDENTITY
With above snippet, sql server will find last order id, saved it into @@IDENTITY, after assigns that value to @OrderID
DECLARE @MyIdent INT
@OrderID = @MyIdent OUTPUT
SELECT * FROM dbo.Orders
WHERE OrderID = @MyIdent
For this snippet, I should understand that @OrderID was storing value from sproc, after push it to @MyIdent or @MyIdent was storing value of @OrderID (sproc), when execute it'll assign value to @OrderID?
Thanks for your reading, any ideas ...