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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 To bcp out a table

Author  Topic 

arthiasha
Starting Member

40 Posts

Posted - 2012-10-17 : 01:10:46
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 sa

i get the error as
SQLState = S0002, NativeError = 208
Error = [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

Mike Jackson
Starting Member

37 Posts

Posted - 2012-10-17 : 08:25:09
you need the database as well as the table

bcp yourdatabase.temp out .\datafiles\temp.dat -S ACER-PC\SQLEXPRESS -U sa -P sa

Mike
Go to Top of Page

arthiasha
Starting Member

40 Posts

Posted - 2012-10-18 : 03:11:39
Thank u...
and also how to import data from .csv file to a table in my db.
I have created a fmt file for temp.

How to import data using bcp command?

C:\inetpub\wwwroot\db>bcp temp in C:\inetpub\wwwroot\db\employee.
csv -w -d mydb -S ACER-PC\SQLEXPRESS -U sa -P sa -t,

Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0]Unexpected EOF encountered in
BCP data-file

0 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 1

I'm getting this error
Please tell me what is wrong in my script?

Go to Top of Page
   

- Advertisement -