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
 Transact-SQL (2008)
 Problems with BCP

Author  Topic 

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-05-15 : 11:21:43
This works

Exec Master..xp_Cmdshell 'bcp Rating.Policy.StatCoding out \\xx\yy\zz\Actuary\Stat.txt -S myServer -c'

but this gives me an error

Exec Master..xp_Cmdshell 'bcp "Select StatCoding From Rating.Policy.StatCoding" queryout \\xx\yy\zz\Actuary\Stat.txt" -S myServer -c'

of

Password:
SQLState = S0002, NativeError = 208
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'Rating.Policy.StatCoding'.
SQLState = 37000, NativeError = 8180
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.
NULL

What I am missing?

Thanks,

Jim

Everyday I learn something that somebody else already knew

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2012-05-15 : 13:55:47
is there such a database
Rating
a schema
.Policy
and a table
.StatCoding

<><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-05-15 : 14:20:03
Try this on your command promt ..If it Runs you can change
it accordingly

bcp "Select StatCoding From Rating.Policy.StatCoding" queryout YourLocalFileLocation -c -S myServer -T


YourLocalFileLocation :--- Make file at your local machine like
D:\Data\yourefile.txt

myServer : Specify DatabaseserverName here

Vijay is here to learn something from you guys.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-05-15 : 15:25:48
That works from the command prompt, but not inside my stored procedure! Thanks, for your help. What's the next step?


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-05-15 : 15:32:14
quote:
Originally posted by jimf

Exec Master..xp_Cmdshell 'bcp "Select StatCoding From Rating.Policy.StatCoding" queryout \\xx\yy\zz\Actuary\Stat.txt" -S myServer -c'

What's up with the extra double quote character after Stat.txt ?



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-05-15 : 15:38:09
A small piece of cheese for Peso! I took out the extra " after txt, but now it gave and unknown argument error.
It doesn't lile the name of my "myServer" which is actually servername\SQL2008.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-05-15 : 15:54:17
put your server name in brackets []. It that doesn't work, try double qoute for the server instance name.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-05-15 : 16:54:22
A full wedge of cheese for Peso! The brackets didn't work but the double quotes did! Thank you so much, I was about to lose my mind!

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -