Last Updated: February 25, 2016
·
466
· purekrome

Exporting/Importing from a Microsoft Sql Server table

Exporting

bcp <database table> out <filename> -T -S <server name> -c
bcp <database table> out <filename> -U <username> -P <password> -S <server name> -c

Eg.

bcp xwing.dbo.Users out "C:\temp\users.data" -T -S MyDatabaseServer -c

NOTE: the -T means: Trusted connection. So this means the logged in user account's permissions will be used to communicate with the database.

Importing

bcp <database table> in <filename> -T -S <server name> -c
bcp <database table> in <filename> -U <username> -P <password> -S <server name> -c

Same as before, except it has an in instead of an out.
This will append to the end of the table. Not overwrite.