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 |
arthiasha
Starting Member
40 Posts |
Posted - 2012-10-17 : 01:27:34
|
Hi,I need to do bcp out of a table which does not hold any data. i need to take the columns alone and store it as a .fmt file.C:\inetpub\wwwroot\db>bcp temp out .\datafiles\temp.dat -S ACER-PC\SQLEXPRESS -U sa -P sai get the error asSQLState = S0002, NativeError = 208Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid object name 'temp'.I'm able to do bcp for all other tables in the db with the same path but not for this table.please help me |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-10-17 : 06:45:27
|
You don't need to have any data in the table to generate a format file. To generate a format file you need to specify the format keyword. So it should be something like this:bcp YourDatabaseName.dbo.temp format nul -f .\datafiles\temp.dat -S ACER-PC\SQLEXPRESS -U sa -P sa But, couple of things:1. The above statement will generate the format file in plain text format. Usually I prefer XML - it is easier to read and edit. 2. I almost always also specify the -c option so I don't have to provide the format information for each column while running the bcp command.So, I would prefer:bcp YourDatabaseName.dbo.temp format nul -f .\datafiles\temp.dat -S ACER-PC\SQLEXPRESS -U sa -P sa -c -x |
|
|
arthiasha
Starting Member
40 Posts |
Posted - 2012-10-17 : 08:17:13
|
thank u so much it worked out |
|
|
|
|
|