How do you insert into single identity table??

This is a discussion on How do you insert into single identity table?? within the Microsoft SQL Server forums in category; I have a table that ONLY has one identity column in it. How do you construct an INSERT statement into a table like this? If you dont use an INSERT statement, then what other way do you insert a record? Table MyId Column1 = MyId int IDENTITY(100000000,1) NOT NULL Using VB6.0 and old ADO, I could create a record using the following lines of code conn.Open(); recordset.Open( SELECT TOP 0 * FROM MyIds , conn) recordset.AddNew recordset.Update id = recordset[0] Some how ADO used an INSERT or some SQL statement to create the row... Does anyone ...

Go Back   Database Forum > Microsoft SQL Server

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-01-2008, 04:35 PM
Default How do you insert into single identity table??

I have a table that ONLY has one identity column in it. How do you construct an INSERT statement into a table like this? If you dont use an INSERT statement, then what other way do you insert a record?

Table MyId
Column1 = MyId int IDENTITY(100000000,1) NOT NULL

Using VB6.0 and old ADO, I could create a record using the following lines of code

conn.Open();
recordset.Open("SELECT TOP 0 * FROM MyIds", conn)
recordset.AddNew
recordset.Update
id = recordset[0]


Some how ADO used an INSERT or some SQL statement to create the row...
Does anyone know how that is done? Is there a way to view a SQL transaction log to see what ADO is doing.. then copy that?

Any help would be great!!!

I am using SQL Server 2005

Below is the script to create the table in question.

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MyIDsTable](
[MyID] [int] IDENTITY(100000000,1) NOT NULL,
CONSTRAINT [PK_MyIDs] PRIMARY KEY NONCLUSTERED
(
[MyID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 04:30 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by bbpixel2008 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.