.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

copy from table to other exist table

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :Sql Server


I tried to insert new values (new rows into table) to Table A according to specific Select query on table A

Table B holds many datarows. I just want to add more from Table A to it.

Both tables are with the same columns (and properties).


I tried this :

FROM     A
WHERE   (YEAR(t_date) = 2009)

 I got an error:

An explicit value for the identity column in table 'Tnuot_Archive' can only be specified when a column list is used and IDENTITY_INSERT is ON.

View Complete Post

More Related Resource Links

Bulk Copy From Datatable To SQL Server Table


 I have read the data of a excle file and captured the data into the dataset to a datatable, now that data is to be inserted into a SQL Server table using bulk copy option. I am using -

 public bool BulkEnterData(DataTable dt, string tblName)
        SqlBulkCopy bulk = new SqlBulkCopy(con);
        bulk.DestinationTableName = tblName;

        return true;

ERROR Getting-
A transport-level error has occurred when receiving results from the server. (provider: Shared Memory Provider, error: 0 - The pipe has been ended.) 

How to resolve the above problem or any other solution is available.


How to copy table data from test to production database

I'm using SQL Server 2008 R2 and I'd like to copy all data rows from one table of a test database to the identical table in a production database. The primary key of the table is referred to by other tables so a DELETE followed by a number of INSERTs won't do it because of referential integrity issues. What is the best method to replace the data rows in the destination database with the values from the source database? Thanks, Guido

InfoPath repeating table Copy values from above row without Code

Hi, I have situation, where I want to copy the values from the above row to the newly created row in a Repeating table. Ex. I have a repeating table with 3 columns ID-Name-FileName. When I enter a data like 1-Customer1-File1.zip and hit "Insert new row", the new row should automatically populate the values of the above row. How can I do it without .Net code. Regards,

copy the image from table to disk drive

i have 2000  image he saved in the table "Employee" and i want to copy this pictures from table to diskdrive and save file name by the ID

Copy table (with content and links) from one page to another

Hi, I'm new to sharepoint and learning this software on my own.  I'm running WinXP Professional.  I've created a table on one page in a subfolder/directory (10Kgold) and would like to use the same table on a page in a different subfolder (24Kgold).  Both subfolders are in the same root folder.  Here are the steps I took: On 10kgold/bracelets.aspx page: right-click on element to copy --> select Copy On 24kgold/bracelets.aspx page: right-click --> Paste On the 24kgold/bracelets page, the "Paste" option was disabled, so then I knew I wouldn't be able to copy/paste the table I copied from 10K gold/bracelets page. I don't want to recreate this table again if I don't have to. Also, I've tried to copy and paste links within the same page, but that doesn't work either. Here are the steps: Select link (yellow-gold) on 10kgold/bracelets page: right-click --> Copy Scroll to where I want to paste the link Right-click (yellow-gold) on 24kgold/bracelets page: --> Paste Is there a way to copy and paste links and tables, etc. from one page to another, with the page/s being in either the same subfolder and/or a different subfolder as long as they are within the same root folder? Thanks in advance for your help.    

Copy Data From one table to another

Hi All, I have a XYZ Database (50 Tables init and lots of data ) on 01 Server and I need to create a XYZ_MOCK Database on same Server 01 with 20 tables of XYZ Similarly with the exact data of XYZ Database.... SO I DID Create XYZ_MOCK database AND 20 TABLES Now there are 20 tables with lots of lots of Records in XYZ ...... All i want is now I need to move all the records from XYZ DB to XYZ_MOCK. DB (20 Selected Tables).. for ex: From Server01-XYZ Database -table abc (20columns and 10,000rows) TO Server01 - XYZ_MOCK Database table abc(20 columns and 10,000rows).... How can i Insert all records for 20 tables so that my Selected tables in Xyz and XYZ_MOCK lokks same Thanks

How to copy sqlServer table into excel sheet with sheet name as sheet1?

hello all,I want to copy each table(from selserver database) in separate sheet of Excelwith Sheet name different from table name..........So the issue is that when I open Excel Sheet it show sheetname same as filename I just want to name it as Sheet1,Sheet2 and so onI can copy table from SqlServer(MS Sql Server 2005) into Excel Sheet as follows:public static void ExportDataTableToExcel(DataTable dt, string filename)         {             System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;             // first let's clean up the response.object             response.Clear();             response.Charset = "";             // set the response mime type for excel             response.ContentType = "application/vnd.ms-excel";             response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");   &nb

How to copy a table record and all related table records linked via relationships...

Hi!I'm using SQL Server 2005 in a project, and i need to duplicate a record from a table and all it's relationships. Can this be done? If so, can anyone tel me how please.

Copy row within same table -Revisited



In a Stored Procedure, I need to copy a row in a table, change some fields and then INSERT the row into the table as a new row. Something like:

Select @Field1=Field1, @Field1 = Filed2, ... @FieldN = FiledN FROM MyDB


Values (MyNew_PK_index, @Field1, @Field2, ... @FieldN )


My problem is that I have 60 something columns in each row and I would like to avoid using that many variables if it's possible.

Can I read the row into an array and then manipulate the members that need to be changed (like PK for example) and then write the array to the table in some simple way? Any other or better way?



Copy from one table to another table???



   i have 2 table   tab1 and tab2.

tab1 has id,fname1.   here id is primary key.

tab2 has id,fname2.    here id is primary key.

i run this 

insert into tab1(id,fname)select id,fname2 from tab2

and i am able to copy from tab2 to tab1.

now i have some changes in tab2 and few more rows are added in tab2.

So i have to update tab1 table with new rows and update the old ones.

How to write query for this?

how to One GridView (table ) Copy to other page Gridview (table)


how to One GridView (table ) Copy to other page  Gridview (table)

Copy and Maintain Active Directory User details into mysql table using C#


For a given Domain name how can I retrieve the AD User details including a Unique identifier so that any changes to the user details including the username can be updated using the unique Identifier.

I can use System.DirectoryServices.DirectoryEntry to get the user details but not able to figure out how to work with the Unique Identifier to maintain the user details consistently.

Please provide me with some sample.

Thank you

Compare if every table entry exist at least once in other table



I have 2 tables:

- Salesmen with Pk.SalesmenID
- Appointments with Fk.SalesmenID and busy(bit)

I want to query:

(Every salesmen has at least one appointment)
(Select non busy salesmen)
(select * from salesmen)

Should I compare distinct counts of both tables?

Purpose is to get salesmens even if there's no appointment made yet. I hope it's somehow logic what I'm trying to explain here :-)

Table Copy Paste Fuctionality issue in Rich Text Box


Hello Team,

I'm working with Rich Text Box in WPF. When I'm trying to Copy a table from MS Word (which does not have borders) and Paste it on Rich text box it looses it's formatting. Instead of table two lines are comming.

Steps to Produce :

1. Open a Ms Word Document and Insert a table(Say 4x4).

2. Apply Design for that table-any  Light Shading - Accent 5 or Accent 4...

3. Copy the table and Paste it on RichTextBox.

Observe the result. It's giving two lines instead of Table which I've copied

This is Urgent requirement for me. Please, Give a solution for this problem


Copy columns within same table


How do I move the data from one column to another column within the same table?

I have work phone numbers that should be in the contact phone number column.

Will the following work:

     UPDATE table1

     SET contact_phone =

    (SELECT work_phone

     FROM table1

     WHERE id IN

     (SELECT id FROM table1)




Copy table values from one database to another


Dear All,

I am stuck with an issue. I have around 200 rows in a table with a particular database. I want to copy those values to another table in a different database.

Pls support

Copy table including triggers and forein keys


Hi All,


Need help.


I've deleted some of the products from the product table. from 32Million to 22 million products. and in that 22 million, I've added 1.2 Million products. Now, I want that 32 million table bacik.


I've that table on another server. and i copied that table to the server I want. but i can copy only data. i can't copy with all indexes, statistics, constraints etc.


Now, I need to get 32 million records into product table.


Any suggestions.. never done it before.and spent enough time. but getting screwed every time. Thanks in advance.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend