[MSSQL]Insert row with non-auto-incrementing unique field?

Associate
Joined
21 May 2003
Posts
1,365
I'm currently working on a new project which is interfacing with someone elses MSSQL database, where I have INSERT / UPDATE / SELECT / DELETE permissions on a table but no ALTER table permissions. I haven't used MSSQL before (all my previous work has been on MySql) so please excuse any glaring holes in my knowledge.

I'm trying to insert a new account into the "accounts" table. The problem is, it's got an "account" field which is set as a unique value and stores the account number, but it's not set to auto-increment. Now if this was my database, i'd call the field "id" and set to auto-increment, but unfortunately I don't have this option.

Is there an SQL keyword I can use to say "insert as next row" rather than having to run an extra query first to find the highest "account" number and then adding 1 before inserting the new row?
 
Back
Top Bottom