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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 INSERT identity but no fields

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-20 : 17:37:45
David writes "Hi,

I have a little bit of a problem. I have a table only has an identity field. I want to insert a new record into the table. All of the variations on the INSERT statement I have tried don't work.

This is a perfectly sensible and legitimate (IMO) thing to do. I have a form that has a number of pieces of information of the same time being submitted at once. I want to group these together, and am grouping them together using the ID from this table. Basically it is a way of grouping together a transaction. I would prefer, for reasons of Referential Integrity, to use a database generated identity rather than generating my own.

One solution is to add in a bit field and to just insert NULL into the field, but it does mean adding a field I am not using.

I am sure that there are other solutions to this that don't involve using a table (eg using a GUID), but I feel that a table is better suited to this problem.

There are a number of other applications of this so it would be good to find some way of doing this."

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2002-01-20 : 17:50:12
David,

Look up BOL for the INSERT statement....


INSERT Table DEFAULT VALUES


DavidM

Tomorrow is the same day as Today was the day before.
Go to Top of Page
   

- Advertisement -