I need this assignNewID as a function. to be called for each row. ( sql 2008, I don't have the sequence object yet )
CREATE PROC Stocks.AssignNewUniqueID( @NewID BIGINT OUTPUT ) AS
DECLARE @TranCounter INT DECLARE @TranCounter2 INT DECLARE @TransactionName VARCHAR(50) = 'TranNameAssignID' SET @TranCounter = @@TRANCOUNT
IF @TranCounter > 0 SAVE TRANSACTION @TransactionName ELSE BEGIN TRAN @TransactionName INSERT INTO Stocks.AssignUniqueIDs DEFAULT VALUES ROLLBACK TRAN @TransactionName SET @NewID = SCOPE_IDENTITY() GO
And what do you need this Function to do? Your sproc code says "take @newID as an input and then set it to the scope_identity". The scope_identity is a function already, so I'm still not clear what you are trying to accomplish.
Jim
Everyday I learn something that somebody else already knew