none
VB.Net - Copying Tables from one SQL Server to Another SQL Server RRS feed

  • Question

  • Hi GURUs,

    I am new to this VB.Net

    Need a guidance how to copy the tables from one SQL Server Database to Another SQL Server Database.

    Need Help to copy the Total Table or to copy the output of a SQL Query.

    Thanks

    Naveen

    Tuesday, March 10, 2015 5:54 AM

Answers

  • Try this forum for SQL Server-related questions.

    Tuesday, March 10, 2015 7:58 AM
  • Try this forum for SQL Server-related questions.

    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?forum=transactsql

    Success
    Cor

    Tuesday, March 10, 2015 8:05 AM
  • I think that you should consider “linked servers” and the “INSERT-SELECT” construct, like this:

        INSERT INTO Server2.Database2.Schema2.Table2 (Column1, Column2)
        SELECT Column3, Column4
        FROM Table1

    These aspects are better to clarify in some SQL forums and try manually before writing the program and asking for more help here.

    Alternatively, you can do it explicitly programmatically: make two connections, get the data using ExecuteReader and a loop, then insert each row using ExecuteNonQuery, but this is probably less recommended.



    • Edited by Viorel_MVP Tuesday, March 10, 2015 8:38 AM
    • Proposed as answer by Rbie Tuesday, March 10, 2015 9:30 AM
    • Marked as answer by Carl CaiModerator Monday, March 23, 2015 7:06 AM
    Tuesday, March 10, 2015 8:30 AM
  • You would script the tables using MS SQL Server Management Studio. You would take the scripts and execute them pointing to the new database using the Management Studio. You can discuss it the MS SQK Server forum as that has been suggested.

    Sunday, March 15, 2015 4:26 PM

All replies

  • Try this forum for SQL Server-related questions.

    Tuesday, March 10, 2015 7:58 AM
  • Try this forum for SQL Server-related questions.

    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?forum=transactsql

    Success
    Cor

    Tuesday, March 10, 2015 8:05 AM
  • I think that you should consider “linked servers” and the “INSERT-SELECT” construct, like this:

        INSERT INTO Server2.Database2.Schema2.Table2 (Column1, Column2)
        SELECT Column3, Column4
        FROM Table1

    These aspects are better to clarify in some SQL forums and try manually before writing the program and asking for more help here.

    Alternatively, you can do it explicitly programmatically: make two connections, get the data using ExecuteReader and a loop, then insert each row using ExecuteNonQuery, but this is probably less recommended.



    • Edited by Viorel_MVP Tuesday, March 10, 2015 8:38 AM
    • Proposed as answer by Rbie Tuesday, March 10, 2015 9:30 AM
    • Marked as answer by Carl CaiModerator Monday, March 23, 2015 7:06 AM
    Tuesday, March 10, 2015 8:30 AM
  • hi,

    yet present i am doing as you said with two different connections...and reading and writing..but if rows and columns are more its taking more time...so thought any option for copying directly from one SQLSERVER to another SQLSERVER...

    Sunday, March 15, 2015 1:30 PM
  • You would script the tables using MS SQL Server Management Studio. You would take the scripts and execute them pointing to the new database using the Management Studio. You can discuss it the MS SQK Server forum as that has been suggested.

    Sunday, March 15, 2015 4:26 PM