Inserting from datas in one table from Multiple tables

Hi guys,

I have a problem with my query. What i want to happen is to populate my table EV_NOTIFICATIONDETAILS (Docownerid, CurrentSentDate, LastSentDate, detailsID, GeneralRemarks) using the datas from the two different tables EV_NOTIFICATIONHEADER and EV_DOCDETAILS.

I tried to create some a query but im having a error. The problem is once i insert the data from datas to the columns Docownerid, CurrentSentDate, LastSentDate the datas are stored in the database and when i tried to insert the remaining columns TO EV_NOTIFICATIONDETAILS detailsID, GeneralRemarks getting the datas from EV_DOCDETAIL it creates a new set of records in the database. Meaning it doesn't update the records in the table EV_NOTIFICATIONDETAILS but it creates a new set of records.

here's my code:

INSERT INTO EV_NOTIFICATIONDETAILS
(Docownerid,
CurrentNoticeSentDate,
LastNoticeSentDate)
SELECT
Docownerid,
CurrentSentDate,
LastSentDate
FROM
EV_NOTIFICATIONHEADER
INSERT INTO EV_NOTIFICATIONDETAILS
(detailsID,
GeneralRemarks)
SELECT
detailsID,
GeneralRemarks
FROM
EV_DOCDETAIL
 


 

 

Any ideas and suggestions will be greatly appreciated. 


Thanks,

*A newbie C# programmer*
0
nhoyti
12/5/2007 9:45:00 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

2 Replies
799 Views

Similar Articles

[PageSpeed] 34

INSERT INTO EV_NOTIFICATIONDETAILS
(Docownerid,
CurrentNoticeSentDate,
LastNoticeSentDate,detailsID,
GeneralRemarks)
SELECT
EV_NOTIFICATIONHEADER.Docownerid,
CurrentSentDate,
LastSentDate,detailsID,
GeneralRemarks

FROM
EV_NOTIFICATIONHEADER INNER JOIN EV_DOCDETAIL

ON EV_NOTIFICATIONHEADER .Docownerid = EV_DOCDETAIL.Docownerid


"Object reference not set to an instance of an object"
0
che3358
12/5/2007 2:02:03 PM
INSERT INTO EV_NOTIFICATIONDETAILS ( Docownerid , CurrentNoticeSentDate , LastNoticeSentDate , detailsID , GeneralRemarks )
SELECT nh.Docownerid , nh.CurrentSentDate , nh.LastSentDate , dd.detailsID , dd.GeneralRemarks
FROM EV_NOTIFICATIONHEADER nh , EV_DOCDETAIL dd
where dd.docownerid = nh.docownerid

Thanks,
Dhimant Trivedi
"When the going gets tough, tough gets going."

"Mark as Answer" the post(s) which helped you solve the problem
0
dhimant
12/5/2007 2:13:00 PM
Reply:

Similar Artilces:

is there an sql statement to insert data to one table and getting the data from another table
Ok I have a table that have general categories with just name and CatNo. Now what I want to know is when I create a client to move all the data in general categories to another table called categories that have the clientid to associate it with the client. I would appreciate for any help what is your question here??Shravan Addaypally MCP...

insert multiple values from one table into one column from another table?
Hi, I'm attempting to create an insert statement that gets the values from multiple columns and insert them into one column from another table, is there a simple solution to do this?Here is something similar to what i'm wanting done, just it's not the correct way to do it, i want value1, value2 and value3 from one table to be combined and put into the value1 column of another table, what am i doing wrong? INSERT INTO tablename2 (value1 + value2 + value3)SELECT value1FROM tablename1 thanks in advance! INSERT INTO tablename2 (SELECT val1 + val2 + val3 FROM tabl...

inserting data from one table to another table..
Hi Guys!  I am stuck on inserting data. Hope you will help me. I have two tables name Customer and Address; Customer(cust_id,name,add_fk);    fk=foreign key,  cust_id and add_id are primary key Address(add_id,street,city,zip); Now, how can I retrieve add_id from Address table and insert into Customer table ( in the add_fk field) using stored procedure with parameters? I am using Oracle 9i.  I would appreciate your help. Thanks! Are you using any of this data in between these actions? (eg: Are they going to reside in your page in a grid, or formview?) ...

Submit Form to insert data into SQL and display with a gridview (edit as well) below how do i insert data into sql table?
I have an asp.net page that has a simple form where a user can submit customers information. Below that I have a gridview which displays customer information submited by the user who is logged in. I have the gridview displaying, sorting and updating as I want however I can't figure out how to bind a button click to insert data into the customer table and then have it refresh the gridview when they submit. Here is the basic code; (I am using AJAX for a calendar when a user wants to edit an appointment date) &lt;div class="leftBar"&gt; <div align=center&...

Inserting Data Into Two Tables (Getting ID from Table 1 and inserting into Table 2)
I am trying to insert data into two different tables. I will insert into Table 2 based on an id I get from the Select Statement from Table1.  Insert Table1(Title,Description,Link,Whatever)Values(@title,@description,@link,@Whatever)Select WhateverID from Table1 Where Description = @DescriptionInsert into Table2(CategoryID,WhateverID)Values(@CategoryID,@WhateverID)  This statement is not working. What should I do? Should I use a stored procedure?? I am writing in C#. Can someone please help!!  Insert Table1(Title,Description,Link,Whatever)Values(@title,@descri...

Problem in inserting data of one table into other table in a dataset
Hi all In my application i have a dataset populated with 2 tables.these 2 tables have been populated from different sources(one is from XML file and another is from another XML File). Now my problem is i want to insert table1 into table2 in the above dataset. How can i do this. Thanks in advance. Regards Ravi Kumar There are a few different ways to do this. From your description, it looks like you just want to iterate through the rows of table1 and call table2.ImportRow for each row in table1. HTH Doug Rothaus douglasr@microsoft.com This posting is provided A...

Detailsview to read data from one table and insert to other table
Hi all, Hop you can help me out on this one - I am really stuck here !This Detailsview initially connects to the table ’trlesson’ and displays the data. What I am trying to achive is, to insert the edited data into another table ‘typerating’ – and not update ‘trlessondata’. In the code you can see both dataconnections; LessonData is where the data initially comes from, and then they are to be inserted in the table ‘typerating’ using the connection ‘typerating' Any suggestions ?Best regards        <body> <form id="form1" runat="serve...

Insert multiple records from one table to another table
Hello. Got a quick problem. I need to post shopping cart items from a temperary table "ShopCart" to a permanent table "tbl_orders". Problem is, I cannot figure out how to iterate through the recordset to post the unique products from "ShopCart" to "tbl_orders". The code below inserts the first product-- but that's it. If there are 6 different products, it will insert the first product 6 times. Public Sub GetShopCart() Dim ordernumber = session("ordernumber") Dim objConn as new SqlConnection(strConn) Dim strSQL as Str...

Stored procedure for insert data from one table to another table
Hi,      I am having 2 tables. One is main table and another is history table. Whenever I update the main table, I need to insert the all the main table data to History table, before updating the main table. Overall it is like storing the history of the table updation. How do i write a stored procedure for this? Anybody has done this before? Pls help me.   I think it's better to implement this logic in your application rather than from SQL side. Your application can accpect a sequence of parameters, and firstly insert them into the history; if ...

Inserting Data into one table with category chosen from another table
Hi, I am a novice programmer. I have this problem and can't seem to find an answer to my problem. I have two tables, an artist and a category table. the artist table have the following fields, name, artist_id and cat_id, and my category table have the following fields, cat_id and category_name. Both tables is connected to each other.  I would like to insert artist names, in form view, and choose the category from a drop downlist. I have no idea how to do this. Can anybody help me. Thank you, Ruan Rossouw  Check this link. It has got example of exactly what you...

Design Question
Hello.I'm wondering what my best options are here....I have one MSSQL2005 table I'll call MSTR_BOL and one called DETAIL_BOL.  The idea is to have one page where a user can enter into MSTR_BOL a header record so to speak.  This header record would have such items as BOL number, Customer number, Carrier and so on.  Then below that (on the form) would be an area to enter DETAIL_BOL items for that MSTR_BOL records.  The link between the two tables would be BOL number.The catch is for a given MSTR_BOL records there are, or can be, multiple MSTR_BOL records.  So, for MSTR...

Inserting distinct data from one table in another table, how?!?Really urgent and needing help!!!
 Hi, I have a table in which I will insert several redundant data. Don't ask why, is Integration services, it only reads data and inserts it in a SQL table. THis way, I have a SQL table with several lines repeating them selves. What I want to do is create a procedure that reads the distinct data and inserts it in another table, but my problem is that I am not able to select data line by line on the original table to save it in local variables and insert it on the another table, I just can select the last line. I've tried a while cycle but no succeed. Here is my code: create...

inserting more than one data row from repeater to a table in database(SQL)
i have a repeater control with four datarows each with a check box, now here what i want to do is insert data in a new table for the data row with selected check box. please can any one help? Hi ankitkedia, Here is a sample: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">        <ItemTemplate>          <table>            <tr>       &nbs...

Inserting data in batch mode in a SQL Table using .NET
Hi, I have an ASP.NET Web Service that accepts a DataSet object passed to it. This DataSet will contain a large number of records in it's table. What I want to do (if possible) is insert all records in a SQL table in a batch mode (one go). Is this doable? Thanks,--Mazen depends on the size of the dataset.Kay LeeMySpace.com - http://www.myspace.com/kragieInfrastructure GroupMySpace.com- Code to live, but Live to code....

Web resources about - Inserting from datas in one table from Multiple tables - asp.net.sql-datasource

Inserting Kate
jurvetson posted a photo: the speaking GPS avatar that we came to love.. more prep photos below... You can hear her voice in the video compilation ...

Inserting the Galaxy Note 5’s S Pen backwards can permanently damage the device
One of the features Samsung highlighted when it unveiled the Galaxy Note 5 was the device's new S Pen slot design. The Note 5 features a spring-loaded ...


Inserting Slavery Into The Climate Debate
Chris Hayes compares the fight against fossil fuels to the abolitionist movement. He states plainly that “there is absolutely no conceivable ...

Samsung smart TVs inserting ads into third-party apps
... playback have pissed off a number of consumers. People with smart TVs from Samsung have been complaining that the electronics maker is inserting ...

Inserting images into Gmail could be so much better
When Google first launched the new compact compose window in Gmail, many of you might have noticed something annoying about inserting images. ...

Gawker tells Steven Crowder to "stop whining, take your licks, and accept that getting hit in the face ...
"... in the middle of an argument between billionaire-funded know-nothing ideologues and people whose livelihoods and stability are being threatened ...

Gmail's New Interface for Inserting Photos
Gmail has a new interface for adding images to a message. When you click the "insert images" icon, Gmail now shows all the photos highlighted ...

Now Samsung SmartTVs are interrupting users' videos by inserting random ads
... room. Now Samsung is dealing with a new headache: Gigaom reports that Samsung SmartTVs are interrupting users' own video content by inserting ...

Samsung SmartTVs are inserting ads into movies - Business Insider
Random Pepsi pop-up ads have been appearing when SmartTV users watch content through the device's third-party apps.

Resources last updated: 11/30/2015 4:25:48 AM