File: Export all tables from a Database to flat files, using bcp, with a field seperator like ';' or other symbol of your choice. By : Albert Ver : 0.1 Date: 28/03/2012 ------------------------------------------------------------------------------------- Suppose the SQL Server 2005/2008 database is called 'mydatabase'. Suppose the SQL Server instance is called SQLCLUS10\SQLCLUS10A (if the database is not clustered, or there are no multiple instances, maybe the -T swich (or the -U -P switches) could already be sufficient). Suppose you want to export all tables to flat files, using bcp, in one run. Suppose the Tables are not too large, or you have ample diskspace to hold all flat files. Then you can use TSQL code like shown below. It will produce bcp commands which can be run from the Operating System prompt, or just put it in a batch file. Need information on "bcp"? You can try "http:\\antapex.org\Import_Export_SQLServer.xls" for more info. DECLARE @tablename varchar(100) DECLARE @sqlstr1 varchar(100) DECLARE @sqlstr2 varchar(100) DECLARE cur1 CURSOR FOR SELECT table_name FROM information_schema.tables OPEN cur1 FETCH NEXT FROM cur1 INTO @tablename set @sqlstr1='bcp mydatabase.dbo.[' set @sqlstr2='.txt -S SQLCLUS10\SQLCLUS10A -c -T -t;' WHILE (@@fetch_status<>-1) BEGIN PRINT @sqlstr1+@tablename+'] out '+@tablename+@sqlstr2 FETCH NEXT FROM cur1 INTO @tablename END CLOSE cur1 DEALLOCATE cur1