Hi everyone, Yesterday I wsa solving a problem in a PosgressSQL database and I found a secuence, is some type of object that create a secuence and can be use as defaul value for a field, so, this fiels should behive like the autonumeric field and can be use as unique key. My cuestion is, is any like this in MSSQL..?
To have an automatically generated and incremented column value in a table you can use an INT column and set it as an IDENTITY. `CREATE TABLE Test (aColumn INT IDENTITY (1,1))` will mean that any row inserted into this table will have a new value, one more than the value of last row inserted. the (1,1) controls where the numbering starts and how big the gaps between numbers are - (10,2) would have numbering start at 10 and new rows would be every 2nd number. There are lots of caveats when using this property of a column, you should read all about it at
As well as the IDENTITY field in SQL Server, in the next version (Denali), there's also the "SEQUENCE". See MS's documentation at , and there are various blog articles about it
including one that I wrote... The main benefit of this is that you can use the same sequence of IDs across multiple tables.