Hi,
Is there any way of capturing the return value of DBCC CHECKIDENT and using that value as a parameter in an SP?
I've tried SET @MyVar = (DBCC CHECKIDENT) and i can't use @MyVar = (SELECT MAX(id) FROM MyTable) + 1 as the next identity value may not be sequential.
If it helps, my table has a SELF JOIN between MailingID (IDENTITY) and ParentID, but i want to set the value of ParentID at runtime to equal that of MailingID if no value is specified by the user.
I thought about using a trigger to take the value of MailingID from the Inserted table, but obviously the self join wont allow a NULL value for ParentID prior to the trigger assigning the value. However do i need the self join as the trigger should maintain referential integrity shouldn't it?
Anyone got any thoughts on how i can go about it?
Cheers,
Leigh
Sure, if it has a microchip in it, it must be IT... Now what seems to be the problem with your toaster...?
Is there any way of capturing the return value of DBCC CHECKIDENT and using that value as a parameter in an SP?
I've tried SET @MyVar = (DBCC CHECKIDENT) and i can't use @MyVar = (SELECT MAX(id) FROM MyTable) + 1 as the next identity value may not be sequential.
If it helps, my table has a SELF JOIN between MailingID (IDENTITY) and ParentID, but i want to set the value of ParentID at runtime to equal that of MailingID if no value is specified by the user.
I thought about using a trigger to take the value of MailingID from the Inserted table, but obviously the self join wont allow a NULL value for ParentID prior to the trigger assigning the value. However do i need the self join as the trigger should maintain referential integrity shouldn't it?
Anyone got any thoughts on how i can go about it?
Cheers,
Leigh
Sure, if it has a microchip in it, it must be IT... Now what seems to be the problem with your toaster...?