Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
fabianus76
Posting Yak Master
191 Posts |
Posted - 2005-10-01 : 19:58:59
|
I would like to create a field that increments automatically by 1 - to use it as an identifier for a row. This is so dammed simple but I can not find how to do it !Thank you very much for any help. By the way I configure SQLExpress with VS2005 and SQL Express Manager. Thank you very much, Regards, Fabianmy favorit hoster is ASPnix : www.aspnix.com ! |
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-10-01 : 22:02:15
|
I don't believe they've changed the syntax on this one.CREATE TABLE test(ident INT IDENTITY(1,1), col1 INT)INSERT test(col1)SELECT 1 UNION ALLSELECT 2SELECT ident, col1FROM testMeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
|
|
fabianus76
Posting Yak Master
191 Posts |
Posted - 2005-10-02 : 05:48:50
|
Hi derrickleggettk, thank you very much! That's what I was looking for. Just one additional question - what is the diffrence between a "Identity-Increment" and a "Identity-Seed"?Regards, Fabianmy favorit hoster is ASPnix : www.aspnix.com ! |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-10-02 : 11:36:39
|
Identity seed is where the number will start at when you create the column. In my example (IDENTITY(1,), it will start the numbers at one, which is the seed, and (,1)) increment by one which is the identity increment.There are two functions (IDENT_SEED and IDENT_INCR) that return what the values were when you created the identity column. Books Online has a LOT of good information like this and is included free with SQL Server. Have you been able to take a look at it yet?MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
|
|
fabianus76
Posting Yak Master
191 Posts |
Posted - 2005-10-02 : 14:53:07
|
Hallo derrickleggett, thank you for your reply. Where do I find books on the web about sql server express? I write that there is a book included for free in sql-server express? I can not find it. Perhaps you could give me a hint to find something. Thank you very much, Regards, Fabainmy favorit hoster is ASPnix : www.aspnix.com ! |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
|
|
|
|
|
|