foreign keys - How to increment (or reserve) IDENTITY value in SQL Server without inserting into table -
Is there any way to reserve or exclude or increment the identity column?
Two tables have been included in one-to-one relation ship. At first there is an identity PK column, and the second is PK (not identifiable). I used to incorporate the first time, get the ID and insert it in another. And it works fine.
Now I need to include values in the second table without first being involved.
Now, how to raise the identity seed, then I can put it in another table, but leave the "hole" in the first table of the ID?
Edit: More info
This works:
- I need a new seed number, But the table is not row - then I will insert the foo line, get the ID, and put it into Table 1 (Somewherepereled) value ('Foo'); SET @ Nude = SCOPE_IDENTITY (); Take away from the table where ID = @ NewID; - So I can insert TABLE2 INSERT (ID, field, field) values (new nude, 'value', 'value');
Once again - it works
Questions Can I get the ID without inserting it into the table?
DBCC needs the rights of the owner; Is there a clean user to do this in a Colebal SQL?
This situation will make your overall data structure very difficult to understand. If there is no connection between values, then break the relationship
Around this, there are ways around what you are looking for, but generally it is in a distributed environment and it has not Due to the data model change appears.
Comments
Post a Comment