question

wbeetge avatar image
wbeetge asked

BCP Command

Can anyone tell if it is possible to use bcp command to insert data directly from a [Server1].[Database1].[Query] to another [Server2].[Database2].[Table] directly ? I can only find references to Query to File and File to Query. Thanks
sql serverbcpbulk
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Oleg avatar image Oleg commented ·
@wbeetge Why do you need bcp? It is trivial to insert records selected from the database table in one instance to the table in another instance via openrowset. Please clarify the reason. Thank you.
0 Likes 0 ·

1 Answer

·
WRBI avatar image
WRBI answered
Just having a look at unanswered questions and trying to provide some answers: 1. As Oleg mentioned in his comment, OPENROWSET would be one solution. [MSDN Link to OPENROWSET ][1] 2. Alternatively, LINKEDSERVERS would be another option. They're good if your going to do it repeatedly. [MSDN link to LINKEDSERVERS][2] [1]: https://docs.microsoft.com/en-us/sql/t-sql/functions/openrowset-transact-sql?view=sql-server-2017 [2]: https://docs.microsoft.com/en-us/sql/relational-databases/linked-servers/linked-servers-database-engine?view=sql-server-2017
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.