How can I Import and export data using bcp command?

你。 提交于 2019-12-12 03:19:42

问题


I am Trying to import and export data using bcp tool but it was giving errors which are:-

  SQLState = 08001, NativeError = -1
Error = [Microsoft][SQL Server Native Client 10.0]SQL Server Network Interfaces:
 Error Locating Server/Instance Specified [xFFFFFFFF].
SQLState = 08001, NativeError = -1
Error = [Microsoft][SQL Server Native Client 10.0]A network-related or instance-
specific error has occurred while establishing a connection to SQL Server. Serve
r is not found or not accessible. Check if instance name is correct and if SQL S
erver is configured to allow remote connections. For more information see SQL Se
rver Books Online.
SQLState = S1T00, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0]Login timeout expired

I am currently using SQL server 2008 r2 version.

Command Which are I am using:-

C:\Program Files\Microsoft SQL Server\100\Tools\Binn>bcp Alldbtypes.dbo.Misc_dty
    pes out C:\Workarea\Data\EmployeeData.dat -S 192.168.1.117\SqlSrv2008 -T

Please suggest me how can I use bcp command.


回答1:


In order to user the bpc, it is important to know the schema of your database.

I believe the Export will look something like this:

bcp "Select Column1, Column2 FROM Database.Schema.Table" queryout
C:\bcp_outputQuery.txt -SYourServerName -T -c

OR something like this:

bcp DatabaseName.Schema.TableName out C:\Data\tableout.txt -c –T

For the import it would look something like this:

bcp Database.Schema.Table in
C:\bcp_outputQuery.txt -SYourServername -T -c


来源:https://stackoverflow.com/questions/38183470/how-can-i-import-and-export-data-using-bcp-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!