Click here to Skip to main content
11,923,046 members (68,359 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# SQL
Hi All,

I have 3 tables like, 'Customer Table', 'Task Table' and 'Enquiry Table'. Here when i update the customer info, those information is saved to 'Customer Table' and generate a customerID. After that I need to insert the enquiry details of that customer (Here Enquiry and task details are Similar), so when I update the enquiry details, I am creating the row in 'Task Table' and in 'Enquiry Table' and generating the ID like TID and EID. Here my challenge is, In 'Customer Table' I have column called "Latest Enquiry" and in 'EnquiryTable' I have a column called "TID", so in these rows I need to update the id(TID from 'Task Table').

Thanks in Advance.
Posted 25-Nov-12 21:00pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Assuming you are using MS SQL Server, you can use SCOPE_IDENTITY()[^] to capture the auto generated ID.

Here is a sample
--Insert Customer data
INSERT INTO Customer(Name, Email) VALUES ('Customer 1', '')
--Store the Auto generated ID in @CustomerID 

Now you can use the "@CustomerID" variable to insert generated customer ID in another table.

Hope this helps.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hi Chetan,

If you want to update TID form task table into customer table and inquiry table then first you need to insert row into Task table and then update task id into inquiry table and finally create customer table and update the id here.

Please let me know if you need any more help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151125.3 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100