I have come up with an interesting topic of using IDENTITY option in SQL Server.
As you know, Identity option is used to create unique values in regular intervals. One of the forum person have asked an interview question like, "Is it possiblel to spawn the identity value across the tables. Since identity is table specific item. How can we acheieve it?"
Nice question right!!!! Let' see how to acheive it?
Option 1:
Create a primary key in the table 1 and refer this column in the other tables. Make the columns in other two tables as primary key.
Option 2:
Create a primary key in one table and refer the column in other two tables. Make the other two tabels column as unique non-clustered index column (or) unique clustered index column else add a unique constraints on the columns in the other table.
Thanks and Regards,
Venkatesan Prabu .J
No comments:
Post a Comment