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)
 Using BCP

Author  Topic 

tinamiller1
Yak Posting Veteran

78 Posts

Posted - 2011-12-29 : 12:48:51
Ok, in my SQL Server 2008 I can do the following:

use cin_cardiology
go
create table test
(id int,
firstname varchar(40),
lastname varchar (40),
admtdate smalldatetime)
go


So that creates a table. Or I can take the .csv file and import it which does the same thing but puts in the data in that .csv file. I was trying to use the bcp utility from the command prompt to input all the data because of the size but it will not work. I get no errors and the DOS screen pops up for a few seconds and then disappears. So then I tried combining all the above code and I did this:

use cin_cardiology
go
create table test
(id int,
firstname varchar(40),
lastname varchar (40),
admtdate smalldatetime)
go

bcp cin_cardiology.dbo.test in c:\documents and settings\desktop\test.csv
go

That does not work either. Is there a way on the bcp utility to do a create table in your main database and the bcp at the same time and why would my bcp not take all the data in the .csv and put it into the table when I run it from the utility area or try it in a script?

tina m miller

edit: moved to proper forum

X002548
Not Just a Number

15586 Posts

Posted - 2011-12-29 : 13:30:50
no the table must exist...and you need -T or a login and password and permission and perhaps -c

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

tinamiller1
Yak Posting Veteran

78 Posts

Posted - 2011-12-29 : 13:31:01
Just an FYI, I tried opening just my command prompt by typing cmd. This way I can see what BCP is actually doing and I get this:

error = microsoft sql server native client 10.0 named pipes provider could not open a connection to sql server 2
sqlstate 08001 nativeerror -2


tina m miller
Go to Top of Page

tinamiller1
Yak Posting Veteran

78 Posts

Posted - 2011-12-29 : 13:45:18
I tried with the -T and it gives me the above error and there is more to it. It says after all the above network related or instance specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. (I have access if I open manager and can connect no issues) check if instance name is correct (have done that) and if SQL server is configured to allow remote connection (I suspect that is the issue as I connect thru VPN to the server and I will bet that using VPN and being a telecommuter we cannot use the bcp utility unless something is turned on)

tina m miller
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-12-29 : 13:51:25
ummmm you need to supply -S and the servername

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-12-29 : 13:53:04
http://msdn.microsoft.com/en-us/library/ms162802.aspx

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-12-29 : 13:55:41
not too far from Blue Mountain

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

tinamiller1
Yak Posting Veteran

78 Posts

Posted - 2012-01-03 : 15:07:05
It is working now thank you

tina m miller
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-03 : 15:28:57


Any Snow in the Poconos?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -