Tuesday, September 7, 2010

Creating format file to bulk insert data from text file

bcp DatabaseName.dbo.TableName format nul -c -f formatfilename -T

for example
bcp AdventureWorks2008R2.HumanResources.Department format nul -c -f Department-c.fmt -T


-T If you are using the window authentication
-c If you want format file to consider all data as char

If you are having more than one instance of the SQL server then you have to give the server name also like

C:\DOCUME~1\ssingh>bcp Northwind.dbo.ResponseTime_VarnishLog format nul -c -f va
rnishformat.fmt -T -S jfkmsc04\sql2008


Where
-S Server Name

No comments:

Post a Comment