2012年2月23日星期四

BCP : Format File : Export Table

Hi,
I have a table in SQL Server 2005 that has the following 3 columns:
Companies Table
=============================
CompanyID CompanyName rowguid
========= =========== =======
I wish to bcp the table out to disk file, but I don't want to export the
rowguid column. Do I have to specify a format file to do this? Is there
something easier I can do as the rowguid column (in my case) is always the
last column in the table. The rowguid column was added by SQL server Merge
replication and I would like to remove it on export.
Thanks
Russell Mangel
Las Vegas, NVRussell Mangel,
Use a query instead the table.
bcp "select c1, c2 from ..." queryout "c:\temp\test" ...
AMB
"Russell Mangel" wrote:

> Hi,
> I have a table in SQL Server 2005 that has the following 3 columns:
> Companies Table
> =============================
> CompanyID CompanyName rowguid
> ========= =========== =======
>
> I wish to bcp the table out to disk file, but I don't want to export the
> rowguid column. Do I have to specify a format file to do this? Is there
> something easier I can do as the rowguid column (in my case) is always the
> last column in the table. The rowguid column was added by SQL server Merge
> replication and I would like to remove it on export.
> Thanks
> Russell Mangel
> Las Vegas, NV
>
>|||Nice, this will work great.
Thanks for your time.
Russell
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:F17553B8-8824-4284-9184-CE1F52B7ECD9@.microsoft.com...
> Russell Mangel,
> Use a query instead the table.
> bcp "select c1, c2 from ..." queryout "c:\temp\test" ...
>
> AMB
> "Russell Mangel" wrote:
>|||Russell Mangel (russell@.tymer.net) writes:
> I have a table in SQL Server 2005 that has the following 3 columns:
> Companies Table
>=============================
> CompanyID CompanyName rowguid
>========= =========== =======
>
> I wish to bcp the table out to disk file, but I don't want to export the
> rowguid column. Do I have to specify a format file to do this? Is there
> something easier I can do as the rowguid column (in my case) is always the
> last column in the table. The rowguid column was added by SQL server Merge
> replication and I would like to remove it on export.
As Alejandro said, you can use the queryout option. However, I have a
feeling that the queryout option can be troublesome. I don't have much
experience with it myself; this is more something I've heard from others.
A second option before going to a format file, is to define a view,
and bulk out from the view.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

没有评论:

发表评论