显示标签为“quoted”的博文。显示所有博文
显示标签为“quoted”的博文。显示所有博文

2012年3月25日星期日

BCP template using quoted text qualifiers

I'm dumping data from a table via BCP and when BCPing them back in to another table, it errors out on numeric and date fields. I'd like to place quote marks on the text fields. How do I do this using BCP?I'd say the other table does not match your structure of the first table

Where's the bcp command and the DDL of the tables.|||The tables are exactly the same. They are duplicates of one another just in different databases.
When I tried to manually import the file that that was exported using BCP I got the error stating that I was trying to put a string into a numeric field. When I exported the table manually with quotes, I had no problem importing it in to the other table.
Do you know how to export a table with the quotes around the text in the file using bcp?|||You can either:
- create a view or;
- create a procedure.

Within either you can embed any character to be part of the data you're trying to export. If it's a view, - use OUT, else - QUERYOUT.|||So there is no switch with the bcp command to put in quotes?sql

2012年3月22日星期四

BCP Quoted CSV

Can anyone clue me in on how to get bcp to output quoted, comma-separated
values
"Bob",50,"Kansas"
"Leslie",44,"California"
etc
thanks ...
Hi
Just using the -r and -t options to produce quotes will miss the first set
of quotes on each line.
You can try something like:
bcp "SELECT
'\"'+au_id,au_lname,au_fname,phone,address,city,st ate,zip,contract FROM
Pubs.dbo.authors" queryout authors.txt -T -t"\",\"" -r"\"" -c
or use the Bulk Export task and DTS:
http://www.sqldts.com/default.aspx?272
John
"Liz" <liz@.tiredofspam.com> wrote in message
news:OvIT7vYKEHA.2244@.tk2msftngp13.phx.gbl...
> Can anyone clue me in on how to get bcp to output quoted, comma-separated
> values
> "Bob",50,"Kansas"
> "Leslie",44,"California"
> etc
> thanks ...
>
>
|||"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:seiic.495$mG1.3946694@.news-text.cableinet.net...

> You can try something like:
> bcp "SELECT
> '\"'+au_id,au_lname,au_fname,phone,address,city,st ate,zip,contract FROM
> Pubs.dbo.authors" queryout authors.txt -T -t"\",\"" -r"\"" -c
thank you; it's so convoluted it almost seems they don't want you to do this
... BUT it works

> or use the Bulk Export task and DTS:
> http://www.sqldts.com/default.aspx?272
interesting ...
[vbcol=seagreen]
> John
> "Liz" <liz@.tiredofspam.com> wrote in message
> news:OvIT7vYKEHA.2244@.tk2msftngp13.phx.gbl...
comma-separated
>
|||Hi
If you wish for a feature to be added to SQL Server you may want to suggest
it by emailing:
sqlwish@.microsoft.com
John
"Liz" <liz@.tiredofspam.com> wrote in message
news:O5ckPlZKEHA.808@.tk2msftngp13.phx.gbl...
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:seiic.495$mG1.3946694@.news-text.cableinet.net...
>
> thank you; it's so convoluted it almost seems they don't want you to do
this
> .. BUT it works
>
> interesting ...
>
>
> comma-separated
>

BCP Quoted CSV

Can anyone clue me in on how to get bcp to output quoted, comma-separated
values
"Bob",50,"Kansas"
"Leslie",44,"California"
etc
thanks ...Hi
Just using the -r and -t options to produce quotes will miss the first set
of quotes on each line.
You can try something like:
bcp "SELECT
'\" '+au_id,au_lname,au_fname,phone,address,
city,state,zip,contract FROM
Pubs.dbo.authors" queryout authors.txt -T -t"\",\"" -r"\"" -c
or use the Bulk Export task and DTS:
http://www.sqldts.com/default.aspx?272
John
"Liz" <liz@.tiredofspam.com> wrote in message
news:OvIT7vYKEHA.2244@.tk2msftngp13.phx.gbl...
> Can anyone clue me in on how to get bcp to output quoted, comma-separated
> values
> "Bob",50,"Kansas"
> "Leslie",44,"California"
> etc
> thanks ...
>
>|||"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:seiic.495$mG1.3946694@.news-text.cableinet.net...

> You can try something like:
> bcp "SELECT
> '\" '+au_id,au_lname,au_fname,phone,address,
city,state,zip,contract FROM
> Pubs.dbo.authors" queryout authors.txt -T -t"\",\"" -r"\"" -c
thank you; it's so convoluted it almost seems they don't want you to do this
.. BUT it works

> or use the Bulk Export task and DTS:
> http://www.sqldts.com/default.aspx?272
interesting ...

> John
> "Liz" <liz@.tiredofspam.com> wrote in message
> news:OvIT7vYKEHA.2244@.tk2msftngp13.phx.gbl...
comma-separated[vbcol=seagreen]
>|||Hi
If you wish for a feature to be added to SQL Server you may want to suggest
it by emailing:
sqlwish@.microsoft.com
John
"Liz" <liz@.tiredofspam.com> wrote in message
news:O5ckPlZKEHA.808@.tk2msftngp13.phx.gbl...
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:seiic.495$mG1.3946694@.news-text.cableinet.net...
>
> thank you; it's so convoluted it almost seems they don't want you to do
this
> .. BUT it works
>
> interesting ...
>
>
> comma-separated
>

BCP Quoted CSV

Can anyone clue me in on how to get bcp to output quoted, comma-separated
values
"Bob",50,"Kansas"
"Leslie",44,"California"
etc
thanks ...Hi
Just using the -r and -t options to produce quotes will miss the first set
of quotes on each line.
You can try something like:
bcp "SELECT
'\"'+au_id,au_lname,au_fname,phone,address,city,state,zip,contract FROM
Pubs.dbo.authors" queryout authors.txt -T -t"\",\"" -r"\"" -c
or use the Bulk Export task and DTS:
http://www.sqldts.com/default.aspx?272
John
"Liz" <liz@.tiredofspam.com> wrote in message
news:OvIT7vYKEHA.2244@.tk2msftngp13.phx.gbl...
> Can anyone clue me in on how to get bcp to output quoted, comma-separated
> values
> "Bob",50,"Kansas"
> "Leslie",44,"California"
> etc
> thanks ...
>
>|||"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:seiic.495$mG1.3946694@.news-text.cableinet.net...
> You can try something like:
> bcp "SELECT
> '\"'+au_id,au_lname,au_fname,phone,address,city,state,zip,contract FROM
> Pubs.dbo.authors" queryout authors.txt -T -t"\",\"" -r"\"" -c
thank you; it's so convoluted it almost seems they don't want you to do this
.. BUT it works
> or use the Bulk Export task and DTS:
> http://www.sqldts.com/default.aspx?272
interesting ...
> John
> "Liz" <liz@.tiredofspam.com> wrote in message
> news:OvIT7vYKEHA.2244@.tk2msftngp13.phx.gbl...
> > Can anyone clue me in on how to get bcp to output quoted,
comma-separated
> > values
> >
> > "Bob",50,"Kansas"
> > "Leslie",44,"California"
> >
> > etc
> >
> > thanks ...
> >
> >
> >
> >
>|||Hi
If you wish for a feature to be added to SQL Server you may want to suggest
it by emailing:
sqlwish@.microsoft.com
John
"Liz" <liz@.tiredofspam.com> wrote in message
news:O5ckPlZKEHA.808@.tk2msftngp13.phx.gbl...
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:seiic.495$mG1.3946694@.news-text.cableinet.net...
> > You can try something like:
> >
> > bcp "SELECT
> > '\"'+au_id,au_lname,au_fname,phone,address,city,state,zip,contract FROM
> > Pubs.dbo.authors" queryout authors.txt -T -t"\",\"" -r"\"" -c
> thank you; it's so convoluted it almost seems they don't want you to do
this
> .. BUT it works
>
> > or use the Bulk Export task and DTS:
> > http://www.sqldts.com/default.aspx?272
> interesting ...
>
>
> > John
> >
> > "Liz" <liz@.tiredofspam.com> wrote in message
> > news:OvIT7vYKEHA.2244@.tk2msftngp13.phx.gbl...
> > > Can anyone clue me in on how to get bcp to output quoted,
> comma-separated
> > > values
> > >
> > > "Bob",50,"Kansas"
> > > "Leslie",44,"California"
> > >
> > > etc
> > >
> > > thanks ...
> > >
> > >
> > >
> > >
> >
> >
>