Showing posts with label bcp. Show all posts
Showing posts with label bcp. Show all posts

Friday, March 23, 2012

-R option in BCP

Hi all,
I m trying to use BCP utility to upload a huge text file.
As per microsoft documentation, -R is used to specify the
regional settings. My computer (client) and the sql server
(running in a network machine) has dd/mm/yyyy as the
regional settings. The incomming text file also has date
in dd/mm/yyyy format. But when i execute BCP with -R
option, i still get an invalid date format error message.
I went through a few microsoft support information, that
told me that SP1 should solve this problem. I got SP3a
installed (both in client and in the server).
So what am i missing here? I m sure some of u here
should have also faced the problem. Any type of help is
greatly appreciated.
thanks and regards,
s.ravi sankarAlready answered in several other ng's.
--
Andrew J. Kelly
SQL Server MVP
"Ravi Sankar" <ravi_pv@.lycos.com> wrote in message
news:0aff01c3b026$b426bfb0$a101280a@.phx.gbl...
> Hi all,
> I m trying to use BCP utility to upload a huge text file.
> As per microsoft documentation, -R is used to specify the
> regional settings. My computer (client) and the sql server
> (running in a network machine) has dd/mm/yyyy as the
> regional settings. The incomming text file also has date
> in dd/mm/yyyy format. But when i execute BCP with -R
> option, i still get an invalid date format error message.
> I went through a few microsoft support information, that
> told me that SP1 should solve this problem. I got SP3a
> installed (both in client and in the server).
> So what am i missing here? I m sure some of u here
> should have also faced the problem. Any type of help is
> greatly appreciated.
> thanks and regards,
> s.ravi sankar
>

Wednesday, March 21, 2012

Quotes In BCP

I'm exporting via BCP. I'd like to have quotes around the text values. In
DTS, you have the text qualifier option. Is there a BCP option that
corresponds to the DTS option known as the Text Qualifier?
"SR" <mv2k_2003-news@.yahoo.com> wrote in message
news:7L9mc.5460$1T4.3283@.newssvr27.news.prodigy.co m...
> I'm exporting via BCP. I'd like to have quotes around the text values. In
> DTS, you have the text qualifier option. Is there a BCP option that
> corresponds to the DTS option known as the Text Qualifier?
>
In checking the BCP options, I could not find one that corresponds to DTS...
Steve
|||I cannot find a BCP way to do what you ask. You cannot make a " be the
field terminator. What you can do is still create a DTS package and run it
from the DTSRUN utility if you needed it to be command line.
Jeff Duncan
MCDBA, MCSE+I
"Steve Thompson" <SteveThompson@.nomail.please> wrote in message
news:eSZSddtMEHA.2468@.TK2MSFTNGP11.phx.gbl...[vbcol=seagreen]
> "SR" <mv2k_2003-news@.yahoo.com> wrote in message
> news:7L9mc.5460$1T4.3283@.newssvr27.news.prodigy.co m...
In
> In checking the BCP options, I could not find one that corresponds to
DTS...
> Steve
>
|||Yeah I knew about the DTS option. Thanks for the help everybody.
"Jeff Duncan" <jduncan@.gtefcu.org> wrote in message
news:%23hpg0CuMEHA.936@.TK2MSFTNGP11.phx.gbl...
> I cannot find a BCP way to do what you ask. You cannot make a " be the
> field terminator. What you can do is still create a DTS package and run
it
> from the DTSRUN utility if you needed it to be command line.
> --
> Jeff Duncan
> MCDBA, MCSE+I
> "Steve Thompson" <SteveThompson@.nomail.please> wrote in message
> news:eSZSddtMEHA.2468@.TK2MSFTNGP11.phx.gbl...
> In
> DTS...
>
|||SR,

> I'm exporting via BCP. I'd like to have quotes around the text
> values. In DTS, you have the text qualifier option. Is there a
> BCP option that corresponds to the DTS option known as the Text
> Qualifier?
You need to use a format file for this. Using the pubs..authors
table as an example, we'll bcp out of a view that looks like this:
use pubs
go
create view authors_csv as
select null first_quote, * from authors
Note that we are including a dummy column called first_quote
that just returns NULL. It's just a little trick to get the leading
quote on the first column.
The format file looks like this:
8.0
10
1 SQLCHAR 0 0 "\"" 1 first_quote ""
2 SQLCHAR 0 11 "\",\"" 2 au_id ""
3 SQLCHAR 0 40 "\",\"" 3 au_lname ""
4 SQLCHAR 0 20 "\",\"" 4 au_fname ""
5 SQLCHAR 0 12 "\",\"" 5 phone ""
6 SQLCHAR 0 40 "\",\"" 6 address ""
7 SQLCHAR 0 20 "\",\"" 7 city ""
8 SQLCHAR 0 2 "\",\"" 8 state ""
9 SQLCHAR 0 5 "\",\"" 9 zip ""
10 SQLCHAR 0 1 "\"\r\n" 10 contract ""
That dummy column is also in the format file to get the leading
quote on au_id.
Here's the command line:
bcp pubs..authors_csv out authors_csv.dat -fauthors_csv.bcp -S. -T
Linda