how would auto increment two columns in a table?
-
I don't understand how I would get around this. I have a author table and after i insert a record i return the authorid I have a book table and after i insert a record i return the bookid and I want to add the bookid to the booknumber table and increment the surrogate number So lets say the bookId is 20 I want to add Bookid=20 and then let the database automatically assign me the next identity number for the surrogatenumber. I could end up with something like Bookid = 20 Surrogatenumber = 250 well In order to get the surrogatenumber to autoincrement I need to set it to an identity field which is fine. but then I can't have the ID of booknumber (which is a primary key) be null so whenever I call my stored procedure I must provide it an ID but I don't have an ID. The two tables are linked from primary key book.id to foreign key booknumber.bookid cause i want to be able to have the same bookid in the booknumber.bookid field but never the same surrogate number basically so i can have several copies of the same book. I been battling this all day long. does someone have any idea how to get around this ? thank you for your time
-
I don't understand how I would get around this. I have a author table and after i insert a record i return the authorid I have a book table and after i insert a record i return the bookid and I want to add the bookid to the booknumber table and increment the surrogate number So lets say the bookId is 20 I want to add Bookid=20 and then let the database automatically assign me the next identity number for the surrogatenumber. I could end up with something like Bookid = 20 Surrogatenumber = 250 well In order to get the surrogatenumber to autoincrement I need to set it to an identity field which is fine. but then I can't have the ID of booknumber (which is a primary key) be null so whenever I call my stored procedure I must provide it an ID but I don't have an ID. The two tables are linked from primary key book.id to foreign key booknumber.bookid cause i want to be able to have the same bookid in the booknumber.bookid field but never the same surrogate number basically so i can have several copies of the same book. I been battling this all day long. does someone have any idea how to get around this ? thank you for your time
First of all, why are posting this to the Linq forum? It has nothing to do with Linq. You should have continued in the Database forum with your previous posts. I'm not sure if I understand the problem. Table Books ID - PK, IDENTITY Table BookNumber ID - PK, IDENTITY BookID - FK to Book table BookNumber.ID will be autoincremented BookNumber.BookID can't be null and should never be null
I know the language. I've read a book. - _Madmatt
-
First of all, why are posting this to the Linq forum? It has nothing to do with Linq. You should have continued in the Database forum with your previous posts. I'm not sure if I understand the problem. Table Books ID - PK, IDENTITY Table BookNumber ID - PK, IDENTITY BookID - FK to Book table BookNumber.ID will be autoincremented BookNumber.BookID can't be null and should never be null
I know the language. I've read a book. - _Madmatt
I am sorry for the double post wasn't sure where to post so I posted both :( Please forgive me and thanks for your reply