Re: copying the column values of a Datatable into another data table in vb.net



Hi Balu,

Are you saying that you want to add a new column to a table and populate it
or populate a column that's already there but is empty? To do that you'll
need to use an update statement and connect the record in the source table
to the record in the target table via a primary key. It's not as easy as
copying/pasting a column in Excel, for example.

In a SQL Server script this would be something like:

Alter Table Target Add NewColumn Integer
Go
Update Target
Set Target.NewColumn =
(Select Source.OldColumn From Source
Where Source.PrimaryKey = Target.PrimaryKey)

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@xxxxxxx www.cindywinegarden.com


"Balu" <balu@xxxxxxxxxxxxxxxxxx> wrote in message
news:eYXluyBEGHA.1676@xxxxxxxxxxxxxxxxxxxxxxx
> Hi,
> Its working fine.But,i wanna copy only one column of a table not the
> entire data.
> But,the statement .....
> tblTwo=tblOne.Copy()
> copies the entire data,i.e.,all column values into another table.
> Can anybody give a solution for it?
>
> Regards,
> Maha.
> "Cindy Winegarden" <cindy_winegarden@xxxxxxx> wrote in message
> news:Ovl72T6DGHA.208@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi Mahalakshmi,
>>
>> Does the Copy() method that Christopher Reed suggested in your other
>> thread work for you?
>>
>>> tblTwo = tblOne.Copy();
>>
>> --
>> Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
>> cindy_winegarden@xxxxxxx www.cindywinegarden.com
>>
>>
>> "Balu" <balu@xxxxxxxxxxxxxxxxxx> wrote in message
>> news:OuE1%2324DGHA.740@xxxxxxxxxxxxxxxxxxxxxxx
>>> Hi All,
>>>
>>> Can anybody tell me how to copy one column of a data table to another
>>> data table.
>>>
>>> Example:I have 2 data tables say dt1,dt2.
>>> Here,i wanna copy only the 1st column values of dt1 into the 1st column
>>> of dt2.
>>> Its an urgent work for me.So,anyone of you can give me a solution to
>>> this.
>>>
>>> Regards,
>>> Mahalakshmi.
>>>
>>
>>
>
>


.



Relevant Pages

  • Re: Materialized View Question
    ... This table is in turn used to populate the target table. ... When applying archive logs in a database recovery, ... I would think that a complete refresh would be required in this case. ...
    (comp.databases.oracle.server)
  • Re: cd /usr/src/etc; make distribute broken.
    ... > As part of my world-building script for creating binary distributions ... > for use on bento I use the following to populate /etc in the target ...
    (freebsd-current)
  • Re: problems with i386 jail on amd64 install 7.0 Release
    ... installworld commands. ... 'TARGET', that is a real variable but not the one you want. ... e.g. did you populate /etc and /var? ... /var/run/ld-elf.so.hints but this is a binary file and I don't know if it is compatible. ...
    (freebsd-questions)
  • Re: cd /usr/src/etc; make distribute broken.
    ... > As part of my world-building script for creating binary distributions ... > for use on bento I use the following to populate /etc in the target ...
    (freebsd-current)