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 |
10pound
Starting Member
2 Posts |
Posted - 2008-02-27 : 18:43:01
|
Thanks in advance for any help you can give.I am new to SQL Server, I'm normally found on an Oracle or MySQL database. I want to insert data into a table on SQL Server 2000 but since there are some 11k records in this table and I want to insert some 9k more, I don't want to manage the Primary Key insertion myself. On Oracle I would just create a sequence and insert using nextval..like thisCREATE SEQUENCE clients_seq;CREATE PUBLIC SYNONYM clients_seq FOR db.clients_seq;GRANT all ON clients_seq TO phase12;INSERT INTO clients VALUES (clients_seq.nextval, 'Cisco');Ive looked high and low and can't seem to find the Microsoft equivalent to this. Can someone point me in the right direction please? Many thanks |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2008-02-27 : 19:04:53
|
Make the primary key column an IDENTITY column. SQL Server will increment the value every time you insert a new row.You can look up IDENTITY in SQL Server Books Online for the details, but here is an example:create table MyTable(MyPK int not null identity(1,1) primary key clustered) CODO ERGO SUM |
 |
|
10pound
Starting Member
2 Posts |
Posted - 2008-02-28 : 18:48:24
|
Thanks for the tip! |
 |
|
|
|
|