The below script will avoid if the columns in the table does have comma or tab space. If it is the case, the below script will take care since the terminator is ** along with tab **
BCP "SELECT * FROM DBName.dbo.TableName (NOLOCK)" QUERYOUT H:\EXPORT\TableName.txt -t "**\t**" -S ServerName -c -T
--Truncate table DBNAME.dbo.TableName
SET identity_insert dbo.TableName on -- This will apply only if you have identity or auto increment
bulk insert dbo.TableName from 'C:\EXPORT\TableName.txt'
with (batchsize=10000,tablock,FIELDTERMINATOR='**\t**',Firstrow=1)
SET identity_insert dbo.TableName off -- This will apply only if you have identity or auto increment
BCP "SELECT * FROM DBName.dbo.TableName (NOLOCK)" QUERYOUT H:\EXPORT\TableName.txt -t "**\t**" -S ServerName -c -T
--Truncate table DBNAME.dbo.TableName
SET identity_insert dbo.TableName on -- This will apply only if you have identity or auto increment
bulk insert dbo.TableName from 'C:\EXPORT\TableName.txt'
with (batchsize=10000,tablock,FIELDTERMINATOR='**\t**',Firstrow=1)
SET identity_insert dbo.TableName off -- This will apply only if you have identity or auto increment
No comments:
Post a Comment