Should the company planning requirements, need a database to import and export the tool with SVN to make the difference matching, easy to plan the database modification of the record tool, I use the bcp command to implement the following batch processing tools, in the middle of a lot of pits, is saved here hope to help the students need this tool.
:: Database Address set ip=127.0.0.1:: Database Account set LOGIN=SA:: Database Password set Passward=passward:: Database name set Database=mydbname:: The path set to save TXT file Filepath=d:\data:: Import into the database (this way comment off the above in is exported from the database to TXT, comment out the following is imported from TXT to the database):: Set Way=in:: Export to txt text set Way=out:: This way, first create a folder, according to personal needs MD%filepath%:: This way fill in the database table name set Datatable=table1 table2 table3 table4 table5 table6:: This is done on an import or export basis to delete a database table, because BCP imports to the database if the original database has data will appear duplicate key does not let insert error causes insert failure if%way% = = in (for%%i in (%datatable%) does osql-s%ip %-u%login%-p%passward%-Q "TRUNCATE TABLE%database%. %%i "):: Here is a table data import and export operation, using the bcp command for%%i in (%datatable%) do bcp%database%: %%i%way%%filepath%%%i.txt-c-S%ip%-u%login%-p%passward%pause
Copy the code into a TXT file, modify the appropriate parameters, save the file in the bat format to use, SQL Server sqlserver2012 test can be used
The bcp command needs to install the Sqlmanagementstudio tool, which is no longer described in the tool and can be found on the web.