Inserting an entry into a table that has one attribute that's an identity column

Inserting an entry into a table that has one attribute that's an identity column

Post by Garrett Kunimur » Sat, 10 Feb 2001 07:56:48



I'm a little stumped on this one.  I'm using MSDE 1.0 and started experimenting
with some data models.  I created a model where a table has one attribute, and I
designated it to be an identity column.  Now, using T-SQL, how do I create a new
record?

Thanks,
Garrett

 
 
 

Inserting an entry into a table that has one attribute that's an identity column

Post by Garok » Sat, 10 Feb 2001 08:22:33


This will add explicit values but you've got me on how to get the row to
create itself with the next value in the identity?

SET IDENTITY_INSERT tablename ON
GO

INSERT INTO tablename (colname) VALUES (1)
GO

SET IDENTITY_INSERT tablename OFF
GO

Cheers,
Gary


I'm a little stumped on this one.  I'm using MSDE 1.0 and started
experimenting
with some data models.  I created a model where a table has one attribute,
and I
designated it to be an identity column.  Now, using T-SQL, how do I create a
new
record?

Thanks,
Garrett

 
 
 

Inserting an entry into a table that has one attribute that's an identity column

Post by BP Margoli » Sat, 10 Feb 2001 09:55:15


Garret,

create table Garret (c1 int IDENTITY)
go

insert into Garret DEFAULT VALUES

select * from Garret

----------------------------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.


I'm a little stumped on this one.  I'm using MSDE 1.0 and started
experimenting
with some data models.  I created a model where a table has one attribute,
and I
designated it to be an identity column.  Now, using T-SQL, how do I create a
new
record?

Thanks,
Garrett

 
 
 

Inserting an entry into a table that has one attribute that's an identity column

Post by Garrett Kunimur » Sun, 11 Feb 2001 05:32:12


Thanks!  I thought it was something simple, but I couldn't find it anywhere in
the documentation I had...
-----Original Message-----

Garret,

create table Garret (c1 int IDENTITY)
go

insert into Garret DEFAULT VALUES

select * from Garret

----------------------------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.



I'm a little stumped on this one.  I'm using MSDE 1.0 and started
experimenting
with some data models.  I created a model where a table has one attribute,
and I
designated it to be an identity column.  Now, using T-SQL, how do I create a
new
record?

Thanks,
Garrett

.