473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Reusing @Identity values

Hi

im still hving a problem with my Identity value that is returned after my insert query

What i have done is inserted a row into a datatable and then used an dataAdapters UPDATE command to push the values into my database
My insert query looks like the following..

ALTER PROCEDURE dbo.InsClientAndSelIdentit

@Surname char(50)
@Forename char(50)
@OrgName varchar(50)
@Address varchar(300)
@Postcode varchar(50)
@PhoneNo varchar(25)
@Identity int OU

A
SET NOCOUNT OFF
INSERT INTO Client(Surname, Forename, OrgName, Address, Postcode, PhoneNo) VALUES (@Surname, @Forename, @OrgName, @Address, @Postcode, @PhoneNo)
SET @Identity = SCOPE_IDENTITY()
Retur

I then assign the returned @Identity value to the datatable the values were pushed from
by using..

Dim myIdentity As SqlParameter = daClient.InsertCommand.Parameters.Add("@Identity", SqlDbType.Int, 0, "ClientID"

The problem is that this puts the value back into the parent table that the UPDATE method was run on. I want to add this value to another child table instead
Is there anyway i can place this returned IDENTITY value into a variable so it can be reused elsewhere??

As im running really short on time, any help would be fantastic
Deadlines :o

Jul 21 '05 #1
0 1104

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

112
by: Andy | last post by:
Hi All! We are doing new development for SQL Server 2000 and also moving from SQL 7.0 to SQL Server 2000. What are cons and pros for using IDENTITY property as PK in SQL SERVER 2000? Please,...
24
by: Ilija_G | last post by:
Hi, Is there any replace for "Select @@identity" that could return "just inserted" GUID as a primary key? Has anyone tested what's faster, working with Guid or Autonumber ?
0
by: Rob Oldfield | last post by:
A strange situation that I've just sorted out, but I'm looking for an explanation... I have a dataset that is pulling information back out of an SQL 2K server. I'm setting the PK values of the...
1
by: Who.Really.Really.Cares | last post by:
Hi! In dynamic SQL I'm inserting a row to a table with an IDENTITY column. How can I retrieve the generated identity value? The statement "VALUES IDENTITY_VAL_LOCAL()" returns the following...
3
by: dusty | last post by:
Hi, I'll try to simplify the problem: I created a table "TestTable" in a database on the SQL server. The first column, 'id', is the primary key with a auto-increment identity. I want to work...
0
by: Bhavna | last post by:
Hi im still hving a problem with my Identity value that is returned after my insert query What i have done is inserted a row into a datatable and then used an dataAdapters UPDATE command to...
41
by: pb648174 | last post by:
In a multi-user environment, I would like to get a list of Ids generated, similar to: declare @LastId int select @LastId = Max(Id) From TableMania INSERT INTO TableMania (ColumnA, ColumnB)...
5
by: Veeru71 | last post by:
Given a table with an identity column (GENERATED BY DEFAULT AS IDENTITY), is there any way to get the last generated value by DB2 for the identity column? I can't use identity_val_local() as...
4
by: Mark Olbert | last post by:
I am struggling with trying to retrieve the value of an autoincrement identity field after a DetailsView Insert operation. The DetailsView is bound to an SqlDataSource control. So far as I can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.