Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Beginer2012
Starting Member
45 Posts |
Posted - 2012-07-13 : 08:39:49
|
| Hello,I need help creating a format file using bcp.All resources I have read on MS web is not clear.Thank you |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-07-13 : 09:02:13
|
It is really pretty simple. Run this command after replacing the database name, view or tablename etc.bcp dbname.dbo.YourViewOrTable format nul -c -f .\YourFormatFile.fmt -x -SYourServerName -Uusername -Ppassword If you have integrated security you don't need the username and password, you can use the -T option.The -x indicates that you want to create the format file in XML format. That is more readable and editable at least to me.There are some caveats, for example, if your column names have spaces in them, I don't know of a way to stop it from choking. |
 |
|
|
Beginer2012
Starting Member
45 Posts |
Posted - 2012-07-13 : 09:37:57
|
Thank you very much. It worked out just fine for me.Have a good dayquote: Originally posted by sunitabeck It is really pretty simple. Run this command after replacing the database name, view or tablename etc.bcp dbname.dbo.YourViewOrTable format nul -c -f .\YourFormatFile.fmt -x -SYourServerName -Uusername -Ppassword If you have integrated security you don't need the username and password, you can use the -T option.The -x indicates that you want to create the format file in XML format. That is more readable and editable at least to me.There are some caveats, for example, if your column names have spaces in them, I don't know of a way to stop it from choking.
|
 |
|
|
Beginer2012
Starting Member
45 Posts |
Posted - 2012-07-16 : 09:33:16
|
Thank you for your help. It worked for me :)quote: Originally posted by Beginer2012 Thank you very much. It worked out just fine for me.Have a good dayquote: Originally posted by sunitabeck It is really pretty simple. Run this command after replacing the database name, view or tablename etc.bcp dbname.dbo.YourViewOrTable format nul -c -f .\YourFormatFile.fmt -x -SYourServerName -Uusername -Ppassword If you have integrated security you don't need the username and password, you can use the -T option.The -x indicates that you want to create the format file in XML format. That is more readable and editable at least to me.There are some caveats, for example, if your column names have spaces in them, I don't know of a way to stop it from choking.
|
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-07-16 : 09:41:11
|
| You are very welcome! :) |
 |
|
|
|
|
|
|
|