Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get New ID
Message
 
 
To
04/05/2000 13:57:19
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Miscellaneous
Thread ID:
00366228
Message ID:
00366242
Views:
11
>Hi everyone!
>
>I am looking for ability to get New ID which will be automatically assigned to my identity setup field, before I insert record.
>basically I need to attach this field to some expression and build it into INSERT command, to provide it to another field.
>
>For example
>
>cStroka = _
>"INSERT INTO mOpt (objectname) VALUES ("& MakePrefix() & [new id] &")"
>objCommand.CommandText =cStroka
>objCommand.Execute

Identitiy fields are not assigned values until a record is actually inserted. There is a field in the one of the system tables you could query to get the next number but you aren't guarenteed that number so it's really useless.

Insert your record and then immediately issue a SELECT @@Identity as 'SomeFieldName'. You can then use this value to update any associated records you may have.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform