-
In C# I want to write the query for copying one table data into another table, can anybody help me?0
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a
member of our community. Consider creating an
account or login.
Replies
-
Administrator • Mar 5, 2012
Share the code you've written so far 😀RAANAIn C# I want to write the query for copying one table data into another table, can anybody help me?Are you sure? This action cannot be undone. -
Member • Mar 6, 2012
you need sql code
INSERT INTO TABLE2 (COL1, COL2, COL3) SELECT COL1, COL4, COL7 FROM TABLE1try this
with ADO.Net concepts apply the above query over database table and you get desired resultsAre you sure? This action cannot be undone. -
Member • Mar 7, 2012
Bulk Copy feature of ADO.NET might help you take a look at that: #-Link-Snipped-#RAANAIn C# I want to write the query for copying one table data into another table, can anybody help me?Are you sure? This action cannot be undone. -
Member • Mar 7, 2012
This is the simplest way to copy a table into another (new) table in the same SQL Server database. This way of copying does not copy constraints and indexes.select * into <destination table> from <source table> Example: Select * into employee_backup from employee
We can also select only a few columns into the destination table like belowselect col1, col2, col3 into <destination table> from <source table> Example: Select empId, empFirstName, empLastName, emgAge into employee_backup from employee
Use this to copy only the structure of the source table.select * into <destination table> from <source table> where 1 = 2 Example: select * into employee_backup from employee where 1=2
Use this to copy a table across two database in the same Sql Server.select * into <destination database.dbo.destination table> from <source database.dbo.source table> Example: select * into Mydatabase2.dbo.employee_backup from mydatabase1.dbo.employee
Any one of the following methods can be employed to copy a table into a destination database on a different SQL Server.1. Data Transformation Service (DTS) â SQL Server 2000.
2. SQL Server Integration Service (SSIS) â SQL Server 2005
3. SQL Server âExport Dataâ task. â SQL Server 2000/2005
4. Create a linked Server of the destination SQL Server on the source SQL Server and then copy the table. â SQL Server 2000/ 2005.
5. We can also use <a href="https://vyaskn.tripod.com/code.htm#tagit" target="_blank" rel="nofollow noopener noreferrer">My code library (SQL Server T-SQL code samples, snippets, examples, tips, tricks, stored procedures, user defined functions, VB programs): Narayana Vyas Kondreddi's home page</a> to generate data insertion scripts and then run the insert scripts.
6. I almost forgot this 😉 you can open the source table , select the row(s), copy (ctrl + C) the row(s), open the destination table and then paste (ctrl + V) the row(s).Are you sure? This action cannot be undone.