Re: AutoNumber ?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Uri Dimant (urid_at_iscar.co.il)
Date: 03/22/04


Date: Mon, 22 Mar 2004 14:19:59 +0200

Peter
You can add an IDENTITY column after yout insertion as well.

CREATE TABLE Test
(
 col INT NOT NULL,
 col1 CHAR(1) NOT NULL
)
GO
----Perfom lots of inserts
INSERT INTO Test VALUES (20,'a')
INSERT INTO Test VALUES (10,'b')
INSERT INTO Test VALUES (50,'c')
INSERT INTO Test VALUES (60,'d')
GO
ALTER TABLE Test ADD col_aut INT IDENTITY(1,1)
GO
SELECT * FROM Test
GO
DROP TABLE Test

"Peter Newman" <anonymous@discussions.microsoft.com> wrote in message
news:AD37C416-EF2E-4AEA-9188-A61167F2255B@microsoft.com...
> im importing a lot of records into a table. The table has no key. Id like
to make a key based on a record number. can i add a field to the table which
is an 'autonumber' field.
>
> and if so how would that effect my insert statement of
> Insert into USEDRecords ( CustNo, StartTime, FinTime) VALUES ( v1, v2,
v3)



Relevant Pages

  • Re: Getting at @@IDENTITY
    ... int ID //identity column ... char 10 fld1 ... Now I need the identity column from that insert. ...
    (microsoft.public.sqlserver.ce)
  • Re: Trigger problems
    ... create table tab1 (col1 int); ... insert into tab3 values; ... CREATE TRIGGER update_tab1 UPDATE ON tab1 ...
    (comp.databases.informix)
  • Re: Few queries
    ... the type of identity column which can be tinyint, smallint, int, bigint, ... You get error message if the identity value greater than ... > C] Can we have DML statements in the body of function? ...
    (microsoft.public.sqlserver.programming)
  • Re: Is this an MSSQL bug?
    ... > I have the following query on MSSQL 2000. ... > declare @t table(i int identity, j int, k int) ... > An explicit value for the identity column in table '@t' can only be ...
    (microsoft.public.sqlserver.programming)
  • Re: Trigger problems
    ... create table tab1 (col1 int); ... insert into tab3 values; ... CREATE TRIGGER update_tab1 UPDATE ON tab1 ...
    (comp.databases.informix)