I have a table with primary key auto increment ID column.
In some cases, I would like to insert the value of the auto increment column into another column in the same table (Without update statement).
Is it possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Does this ID value go into another column of the same row when it does go in? If so I would think that you could make this other column a calculated column that returns the ID column under certain conditions.
Other than that I can’t think of any way you can put a value into place without an update or insert statement of some kind. However when you end up doing it with an update or insert statement you can get the last ID generated using SCOPE_IDENTITY(), and you can also get the values that were inserted in some other statement by adding an OUTPUT clause. See http://msdn.microsoft.com/en-us/library/ms174335.aspx.