Is there a way to automatically copy an auto incremented identity int column into another column?
create table dbo.CopyOfIdColumn
(
myIdCol int identity(1,1)
,copyOfMyIdCol int Default (I WANT THE DEFAULT TO BE WHATEVER THE VALUE OF myIdCol IS)
)
I know I can wrap in a stored procedure and just update the entry based on the inserted record using something from Best way to get identity of inserted row? post, probably SCOPE_IDENTITY(), but I'm hoping for a simpler/easier way.
Thanks in advance.
UPDATE: Per Panagiotis Kanavos's suggestion, updating the question to better indicate what I want to achieve.
What I want to do is have a column that indicates the parent for a row (often itself). I would prefer for the column to not have null values.
I also don't want an extra table. Parents and children have the same data and I don't want to have a table with just parentIds. His suggestion is that I can achieve this with a Default constraint.