Quick Method for Export and Import data in SQL Server (BCP out/BCP in)

We can export and import data in SQL Server with faster performance with this method. All we have to do is :

1)    Export:

Open command promt console then type the query bellow :

bcp NameDB.SchemaName.TableName out path\filename Parameters  ServerName

Example :
bcp LBUSDB.dbo.users out d:\users.txt -c -T

If you have a named instance, use -S Instancename

You can export a query :
bcp “query  from NameDB.SchemaName.TableName ” queryout path\filename Parameters ServerName

Example :
bcp “select * from LBUSDB.dbo.users ” queryout d:\query.txt -c –T –S DATABASESERVER

2)    Import :

Open command promt console then type the query bellow :

NameDB. SchemaName. TableName in path\filename parameters ServerName

Example :
bcp LBUSDB.dbo.users in d:\alamzyah.txt -c -T -S DATABASESERVER

Advertisements