In T-SQL (MS SQL Server) you use the IDENTITY property:
"IDENTITY [(seed, increment )]
seed Is the value that is used for the very first row loaded into the table.
increment Is the incremental value that is added to the identity value of the previous row that was loaded."
One thing you really shouldn't do is try and roll your own unless you really know what you are doing and can handle concurrency etc.
Edit: Why you need to be careful:
Here's some pseudo SQL that shows the danger of using your own increment etc:
1. @NextID = SELECT MAX(ID) FROM MyTable;
2. INSERT INTO MyTable(ID + 1, Name) VALUES (@NextID, "Dan");
Now, in most cases this would work OK. However, in a high volume database there is always a chance that another insert statement might occur between steps 1 and 2. You'd then end up with a primary key violation and an error. It may not happen often, but when it does it would be a pain to pinpoint.
The way around this is to have a LOCK before step 1 and release it after step 2. This effectively queues alls transactions and the database runs in "single user" mode. In high volume systems this can be very detrimental to performance.
This is why all major databases have sequences or built-in methods for auto-incremementing primary keys.