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
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 New BCP Problem

Author  Topic 

tinamiller1
Yak Posting Veteran

78 Posts

Posted - 2011-12-30 : 14:59:42
Ok. I went in and used the import function to import data. Has column headers and a few lines of data. Did this in SQL Server 2008 and it is table dbo.test

I did my bcp stuff and this is what it looks like from my command prompt

c:\bcp cin_nos.dbo.test in "c:\documents and settings\myusername\desktop\temp.csv" -SServerName -T -n

I enter and the response is:

starting copy......
0 rows copied
Network packet size <bytes>: 4096
Clock Time <ms.> Total :1

So I thought ok maybe because I still have the column headers in the temp.csv file I should remove that. So I did and just have data and did the exact same entry as above and got the same response.

So it is not erroring. I have my SQL Server 2008 actually open where the data is to go but nothing is moving into this table.

Any advice?

tina m miller

edit: moved to proper forum

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-01-01 : 11:58:04
If it is a one time thing, that you just want to get a file into the database, you could try to import using Import/Export Wizard (from SSMS Object Explorer, right click the database name, Tasks->Import Data and follow the directions of the wizard).

If you are setting up something to use repeatedly: I have seen this problem (i.e., it does not copy any rows) when the field terminator and/or the row terminator are different from the default values (which are TAB and \n. You can specify the field and row terminators using the -r and -t options (see here: http://msdn.microsoft.com/en-us/library/ms162802.aspx)
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2012-01-01 : 13:46:16
How about trying BULK INSERT instead ?

Bulk Insert cin_nos.dbo.test from 'c:\documents and settings\myusername\desktop\temp.csv' with(fieldterminator='\t',rowterminator='\n')
Go to Top of Page

tinamiller1
Yak Posting Veteran

78 Posts

Posted - 2012-01-03 : 10:16:07
Thanks but bulk insert does not work for us. Our co. turned it off and they told us to use bcp instead from the cmd prompt. The only issue is I am not sure how to formet this -t with the bcp command. Will the with and layout you have work also with bcp. I get errors when attempting


tina m miller
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2012-01-03 : 10:46:18
Could you post some sample data of the csv file and what seperator are you using ?

After Monday and Tuesday even the calendar says W T F ....
Go to Top of Page
   

- Advertisement -