Export error bcp execution

hi i been trying to export some data with the bcp utility but is generating some errors... this is how i been trying to do:
  • Remove From My Forums
  • Question

  • hi i been trying to export some data with the bcp utility but is generating some errors… this is how i been trying to do:

    declare @sql varchar(8000)

    select @sql = ‘bcp » SELECT cod_tipo_regist FROM OfacGob.temp ORDER BY SQN» queryout c:bcptest.txt -U jaja -P jaja -T -S @@SERVERNAME’

    exec master..xp_cmdshell @sql

    the errors are these :

    SQLState = 08001, NativeError = 53

    Error = [Microsoft][SQL Native Client]Named Pipes Provider: Could not open a connection to SQL Server [53]. 

    SQLState = HYT00, NativeError = 0

    Error = [Microsoft][SQL Native Client]Login timeout expired

    SQLState = 08001, NativeError = 53

    Error = [Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connecti

    ons.

    NULL

    i read that default settings SQL Server don;t allow remote connections but i am doing it local and also i keep reading and change the settings to allow remote connections but is generating the same error….  any help is really appreciated please …. THANKS!!


    «Everything is worthless if you don’t give yourself a chance to try» by me… ;P

Answers

  • i am going to cry!! jejejeje i almost get it!!!!!!! jejejej i put in the FROM FROM OfacGob.dbo.temp the dbo!!!! jejejejje UUU but know the things is that is print it with a  no printible char!!! maybe i need to use a format file to export it!!! i am going to keep trying thanks guys for the help!!! this forum is the BEST!!!! 

    THANKS!!!


    «Everything is worthless if you don’t give yourself a chance to try» by me… ;P

    • Marked as answer by

      Tuesday, July 21, 2009 8:07 PM

  • Remove From My Forums
  • Вопрос

  • SQLState = S0002, NativeError = 208
    Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid object name ‘SGMH_Reports.dbo.sp_RadLog’.
    SQLState = 37000, NativeError = 8180
    Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement(s) could not be prepared.
    NULL

    QUERY:

    set @FileName =Convert(varchar(2),DatePart(MM,@EndDate))+’_’+
                  Convert(varchar(2),DatePart(DD,@EndDate))+’_’+
                  Convert(varchar(4),DatePart(YYYY,@EndDate))
    Set @FileLoc = ‘\sangorbandc02dataFTPResendRADADT’
    —Set @FileLoc = ‘\it-dbaC$TestFiles’
    Set @Command = ‘bcp «Select * from SGMH_Reports.dbo.sp_RadLog» queryout «‘+
                    RTrim(LTrim(@FileLoc))+’ADT_’+@FileName+’.txt» -T -c -t^|’
    print @Command


    YFLORES

Ответы

  • is this a valid object SGMH_Reports.dbo.sp_RadLog? Can you query this table?

    Select * from SGMH_Reports.dbo.sp_RadLog

    If So, can you mention -S <ServerName> in the bcp command ?

    Set @Command = 'bcp "Select * from SGMH_Reports.dbo.sp_RadLog" queryout "'+
                    RTrim(LTrim(@FileLoc))+'ADT_'+@FileName+'.txt" -S <ServerName> -T -c -t^|'

    -Prashanth

    • Изменено

      10 марта 2014 г. 17:09

    • Помечено в качестве ответа
      Kalman Toth
      20 марта 2014 г. 16:25

  • You’re not passing servername. So it gets connected to default instance. Are you sure you’ve database SGMH_Reports
    in it? My guess is it might be database from another named instance within the machine. In that case pass server name using -S switch.

    see

    http://visakhm.blogspot.in/2013/10/bcp-out-custom-format-data-to-flat-file.html


    Please Mark This As Answer if it helps to solve the issue Visakh —————————- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

    • Помечено в качестве ответа
      Kalman Toth
      20 марта 2014 г. 16:25

  • Yes SGMH is in the same Instance. so servname of where the file is going? 

    @@servername is the name the instance you are running from. If you don’t specify -S, BCP will attempt to connect to the default instance on the server. Which may be a different instance from the one you are running on.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

    • Помечено в качестве ответа
      Kalman Toth
      20 марта 2014 г. 16:23

All, I have a BCP export query. It is failing with the useless error mesage on BCP usage:

usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h «load hints»] [-x generate xml format file]
[-d database name]
NULL

The query I am using is as follows

DECLARE @SQL VARCHAR(8000); 
SELECT @SQL = 'bcp "EXEC ispsSelectEmptyAsNull ''B1A'';" 
               queryout "F:aaDataIPACostDataR15TData2BSHAEOS_B1A_20121120.txt" 
               -f "F:aaDataIPACostDataR15TDatatmpFormatCard_B1A.fmt" -T -S' + @@SERVERNAME + ''; 
EXEC xp_cmdshell @SQL;
GO

where if I replace EXEC ispsSelectEmptyAsNull ''B1A''; with SELECT * FROM B1A; there is not problem. The query EXEC ispsSelectEmptyAsNull ''B1A''; itself runs with no problems and returns the correct result set. I have run a million BCP queries but never using an SP to provide the result set. Am I doing this correct?

The SP is as follows:

IF EXISTS (SELECT name 
           FROM sys.procedures 
           WHERE name = N'ispsSelectEmptyAsNull') 
DROP PROCEDURE ispsSelectEmptyAsNull;
GO
CREATE PROCEDURE ispsSelectEmptyAsNull @TableName NVARCHAR(256)         
AS    
DECLARE @Columns VARCHAR(MAX);
SELECT @Columns =  
    COALESCE(@Columns + N', 
    NULLIF([' + CAST(COLUMN_NAME AS VARCHAR) + N'], '''') AS ' + COLUMN_NAME + '',
  N'NULLIF([' + CAST(COLUMN_NAME AS VARCHAR) + N'], '''') AS ' + COLUMN_NAME + '') 
FROM (SELECT DISTINCT COLUMN_NAME 
      FROM [IPACostAdmin].INFORMATION_SCHEMA.COLUMNS 
      WHERE TABLE_NAME = @TableName) AS H 
ORDER BY COLUMN_NAME; 
DECLARE @SQL NVARCHAR(MAX);
SET @SQL = N'
    SELECT ' + @Columns + N' 
    FROM ' + @TableName + N';';
-- SELECT CONVERT(XML, @SQL);
EXEC (@SQL);
GO

Thanks very much for your time.

Ps. I do not care about SQL injection etc.

title description ms.service ms.subservice ms.topic helpviewer_keywords author ms.author ms.reviewer ms.custom ms.date monikerRange

bcp Utility

The bulk copy program (bcp) utility bulk copies data between an instance of SQL Server and a data file in a user-specified format.

sql

tools-other

conceptual

bcp utility [SQL Server]

exporting data

row exporting [SQL Server]

copying data [SQL Server], bcp utility

command prompt utilities [SQL Server], bcp

tables [SQL Server], importing data

column importing [SQL Server]

bcp utility [SQL Server], command options

file exporting [SQL Server]

bulk copy [SQL Server]

bcp utility [SQL Server], about bcp utility

tables [SQL Server], exporting data

row importing [SQL Server]

importing data, bcp utility

file importing [SQL Server]

column exporting [SQL Server]

markingmyname

maghan

v-davidengel

seo-lt-2019

12/13/2021

>=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017

bcp Utility

[!INCLUDESQL Server Azure SQL Database Synapse Analytics PDW ]

For using bcp on Linux, see Install sqlcmd and bcp on Linux.

For detailed information about using bcp with Azure Synapse Analytics, see Load data with bcp.

The bulk copy program utility (bcp) bulk copies data between an instance of [!INCLUDEmsCoName] [!INCLUDEssNoVersion] and a data file in a user-specified format. The bcp utility can be used to import large numbers of new rows into [!INCLUDEssNoVersion] tables or to export data out of tables into data files. Except when used with the queryout option, the utility requires no knowledge of [!INCLUDEtsql]. To import data into a table, you must either use a format file created for that table or understand the structure of the table and the types of data that are valid for its columns.

:::image type=»icon» source=»../includes/media/topic-link-icon.svg» border=»false»::: For the syntax conventions that are used for the bcp syntax, see Transact-SQL syntax conventions.

[!NOTE]
If you use bcp to back up your data, create a format file to record the data format. bcp data files do not include any schema or format information, so if a table or view is dropped and you do not have a format file, you may be unable to import the data.

Download the latest version of bcp Utility

:::image type=»icon» source=»../includes/media/download.svg» border=»false»::: Download Microsoft Command Line Utilities 15 for SQL Server (x64)
:::image type=»icon» source=»../includes/media/download.svg» border=»false»::: Download Microsoft Command Line Utilities 15 for SQL Server (x86)

The command-line tools are General Availability (GA), however they’re being released with the installer package for [!INCLUDEsql-server-2019].

Version Information

Release number: 15.0.2
Build number: 15.0.2000.5
Release date: September 11, 2020

The new version of SQLCMD supports Azure AD authentication, including Multi-Factor Authentication (MFA) support for SQL Database, Azure Synapse Analytics, and Always Encrypted features.
The new BCP supports Azure AD authentication, including Multi-Factor Authentication (MFA) support for SQL Database and Azure Synapse Analytics.

System Requirements

Windows 11, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2008 R2 SP1, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019, Windows Server 2022

This component requires both Windows Installer 4.5 and Microsoft ODBC Driver 17 for SQL Server.

To check the BCP version execute bcp /v command and confirm that 15.0.2000.5 or higher is in use.

Syntax
bcp [database_name.] schema.{table_name | view_name | "query"}
    {in data_file | out data_file | queryout data_file | format nul}
                                                                                                         
    [-a packet_size]
    [-b batch_size]
    [-c]
    [-C { ACP | OEM | RAW | code_page } ]
    [-d database_name]
    [-D]
    [-e err_file]
    [-E]
    [-f format_file]
    [-F first_row]
    [-G Azure Active Directory Authentication]
    [-h"hint [,...n]"]
    [-i input_file]
    [-k]
    [-K application_intent]
    [-l login_timeout]
    [-L last_row]
    [-m max_errors]
    [-n]
    [-N]
    [-o output_file]
    [-P password]
    [-q]
    [-r row_term]
    [-R]
    [-S [server_name[instance_name]]
    [-t field_term]
    [-T]
    [-U login_id]
    [-v]
    [-V (80 | 90 | 100 | 110 | 120 | 130 ) ]
    [-w]
    [-x]

Arguments

data_file
Is the full path of the data file. When data is bulk imported into [!INCLUDEssNoVersion], the data file contains the data to be copied into the specified table or view. When data is bulk exported from [!INCLUDEssNoVersion], the data file contains the data copied from the table or view. The path can have from 1 through 255 characters. The data file can contain a maximum of 2^63 — 1 rows.

database_name
Is the name of the database in which the specified table or view resides. If not specified, this is the default database for the user.

You can also explicitly specify the database name with -d.

in data_file | out data_file | queryout data_file | format nul
Specifies the direction of the bulk copy, as follows:

  • in copies from a file into the database table or view.

  • out copies from the database table or view to a file. If you specify an existing file, the file is overwritten. When extracting data, the bcp utility represents an empty string as a null and a null string as an empty string.

  • queryout copies from a query and must be specified only when bulk copying data from a query.

  • format creates a format file based on the option specified (-n, -c, -w, or -N) and the table or view delimiters. When bulk copying data, the bcp command can refer to a format file, which saves you from reentering format information interactively. The format option requires the -f option; creating an XML format file, also requires the -x option. For more information, see Create a Format File (SQL Server). You must specify nul as the value (format nul).

schema
Is the name of the owner of the table or view. schema is optional if the user performing the operation owns the specified table or view. If schema is not specified and the user performing the operation does not own the specified table or view, [!INCLUDEssNoVersion] returns an error message, and the operation is canceled.

« query «
Is a [!INCLUDEtsql] query that returns a result set. If the query returns multiple result sets, only the first result set is copied to the data file; subsequent result sets are ignored. Use double quotation marks around the query and single quotation marks around anything embedded in the query. queryout must also be specified when bulk copying data from a query.

The query can reference a stored procedure as long as all tables referenced inside the stored procedure exist prior to executing the bcp statement. For example, if the stored procedure generates a temp table, the bcp statement fails because the temp table is available only at run time and not at statement execution time. In this case, consider inserting the results of the stored procedure into a table and then use bcp to copy the data from the table into a data file.

table_name
Is the name of the destination table when importing data into [!INCLUDEssNoVersion] (in), and the source table when exporting data from [!INCLUDEssNoVersion] (out).

view_name
Is the name of the destination view when copying data into [!INCLUDEssNoVersion] (in), and the source view when copying data from [!INCLUDEssNoVersion] (out). Only views in which all columns refer to the same table can be used as destination views. For more information on the restrictions for copying data into views, see INSERT (Transact-SQL).

-a packet_size
Specifies the number of bytes, per network packet, sent to and from the server. A server configuration option can be set by using [!INCLUDEssManStudioFull] (or the sp_configure system stored procedure). However, the server configuration option can be overridden on an individual basis by using this option. packet_size can be from 4096 bytes to 65535 bytes; the default is 4096.

Increased packet size can enhance performance of bulk-copy operations. If a larger packet is requested but cannot be granted, the default is used. The performance statistics generated by the bcp utility show the packet size used.

-b batch_size
Specifies the number of rows per batch of imported data. Each batch is imported and logged as a separate transaction that imports the whole batch before being committed. By default, all the rows in the data file are imported as one batch. To distribute the rows among multiple batches, specify a batch_size that is smaller than the number of rows in the data file. If the transaction for any batch fails, only insertions from the current batch are rolled back. Batches already imported by committed transactions are unaffected by a later failure.

Do not use this option in conjunction with the -h «ROWS_PER_BATCH =bb« option.

-c
Performs the operation using a character data type. This option does not prompt for each field; it uses char as the storage type, without prefixes and with t (tab character) as the field separator and rn (newline character) as the row terminator. -c is not compatible with -w.

For more information, see Use Character Format to Import or Export Data (SQL Server).

-C { ACP | OEM | RAW | code_page }
Specifies the code page of the data in the data file. code_page is relevant only if the data contains char, varchar, or text columns with character values greater than 127 or less than 32.

[!NOTE]
We recommend specifying a collation name for each column in a format file, except when you want the 65001 option to have priority over the collation/code page specification.

Code page value Description
ACP [!INCLUDEvcpransi]/Microsoft Windows (ISO 1252).
OEM Default code page used by the client. This is the default code page used if -C is not specified.
RAW No conversion from one code page to another occurs. This is the fastest option because no conversion occurs.
code_page Specific code page number; for example, 850.

Versions prior to version 13 ([!INCLUDEsssql15-md]) do not support code page 65001 (UTF-8 encoding). Versions beginning with 13 can import UTF-8 encoding to earlier versions of [!INCLUDEssNoVersion].

-d database_name
Specifies the database to connect to. By default, bcp.exe connects to the user’s default database. If -d database_name and a three part name (database_name.schema.table, passed as the first parameter to bcp.exe) are specified, an error will occur because you cannot specify the database name twice. If database_name begins with a hyphen (-) or a forward slash (/), do not add a space between -d and the database name.

-D
Causes the value passed to the bcp -S option to be interpreted as a data source name (DSN). A DSN may be used to embed driver options to simplify command lines, enforce driver options that are not otherwise accessible from the command line such as MultiSubnetFailover, or to help protect sensitive credentials from being discoverable as command line arguments. For more information, see DSN Support in sqlcmd and bcp in Connecting with sqlcmd.

-e err_file
Specifies the full path of an error file used to store any rows that the bcp utility cannot transfer from the file to the database. Error messages from the bcp command go to the workstation of the user. If this option is not used, an error file is not created.

If err_file begins with a hyphen (-) or a forward slash (/), do not include a space between -e and the err_file value.

-E

Specifies that identity value or values in the imported data file are to be used for the identity column. If -E is not given, the identity values for this column in the data file being imported are ignored, and [!INCLUDEssNoVersion] automatically assigns unique values based on the seed and increment values specified during table creation. For more information, see DBCC CHECKIDENT.

If the data file does not contain values for the identity column in the table or view, use a format file to specify that the identity column in the table or view should be skipped when importing data; [!INCLUDEssNoVersion] automatically assigns unique values for the column.

The -E option has a special permissions requirement. For more information, see «Remarks» later in this topic.

-f format_file
Specifies the full path of a format file. The meaning of this option depends on the environment in which it is used, as follows:

  • If -f is used with the format option, the specified format_file is created for the specified table or view. To create an XML format file, also specify the -x option. For more information, see Create a Format File (SQL Server).

  • If used with the in or out option, -f requires an existing format file.

    [!NOTE]
    Using a format file in with the in or out option is optional. In the absence of the -f option, if -n, -c, -w, or -N is not specified, the command prompts for format information and lets you save your responses in a format file (whose default file name is Bcp.fmt).

If format_file begins with a hyphen (-) or a forward slash (/), do not include a space between -f and the format_file value.

-F first_row
Specifies the number of the first row to export from a table or import from a data file. This parameter requires a value greater than (>) 0 but less than (<) or equal to (=) the total number rows. In the absence of this parameter, the default is the first row of the file.

first_row can be a positive integer with a value up to 2^63-1. -F first_row is 1-based.

-G

This switch is used by the client when connecting to Azure SQL Database or Azure Synapse Analytics to specify that the user be authenticated using Azure Active Directory authentication. The -G switch requires version 14.0.3008.27 or later. To determine your version, execute bcp -v. For more information, see Use Azure Active Directory Authentication for authentication with SQL Database or Azure Synapse Analytics.

[!IMPORTANT]
The -G option only applies to Azure SQL Database and Azure Synapse Analytics.
AAD Interactive Authentication is not currently supported on Linux or macOS. AAD Integrated Authentication requires Microsoft ODBC Driver 17 for SQL Server version 17.6.1 or higher and a properly configured Kerberos environment.

[!TIP]
To check if your version of bcp includes support for Azure Active Directory Authentication (AAD) type bcp — (bcp<space><dash><dash>) and verify that you see -G in the list of available arguments.

  • Azure Active Directory Username and Password:

    When you want to use an Azure Active Directory user name and password, you can provide the -G option and also use the user name and password by providing the -U and -P options.

    The following example exports data using Azure AD Username and Password where user and password is an AAD credential. The example exports table bcptest from database testdb from Azure server aadserver.database.windows.net and stores the data in file c:lastdata1.dat:

    bcp bcptest out "c:lastdata1.dat" -c -t -S aadserver.database.windows.net -d testdb -G -U alice@aadtest.onmicrosoft.com -P xxxxx

    The following example imports data using Azure AD Username and Password where user and password is an AAD credential. The example imports data from file c:lastdata1.dat into table bcptest for database testdb on Azure server aadserver.database.windows.net using Azure AD User/Password:

    bcp bcptest in "c:lastdata1.dat" -c -t -S aadserver.database.windows.net -d testdb -G -U alice@aadtest.onmicrosoft.com -P xxxxx
  • Azure Active Directory Integrated

    For Azure Active Directory Integrated authentication, provide the -G option without a user name or password. This configuration assumes that the current Windows user account (the account the bcp command is running under) is federated with Azure AD:

    The following example exports data using Azure AD-Integrated account. The example exports table bcptest from database testdb using Azure AD Integrated from Azure server aadserver.database.windows.net and stores the data in file c:lastdata2.dat:

    bcp bcptest out "c:lastdata2.dat" -S aadserver.database.windows.net -d testdb -G -c -t

    The following example imports data using Azure AD-Integrated auth. The example imports data from file c:lastdata2.txt into table bcptest for database testdb on Azure server aadserver.database.windows.net using Azure AD Integrated auth:

    bcp bcptest in "c:lastdata2.dat" -S aadserver.database.windows.net -d testdb -G -c -t
  • Azure Active Directory Interactive

    The Azure AD Interactive authentication for Azure SQL Database and Azure Synapse Analytics, allows you to use an interactive method supporting multi-factor authentication. For more information, see Active Directory Interactive Authentication.

    Azure AD interactive requires bcp version 15.0.1000.34 or later as well as ODBC version 17.2 or later.

    To enable interactive authentication, provide -G option with user name (-U) only, without a password.

    The following example exports data using Azure AD interactive mode indicating username where user represents an AAD account. This is the same example used in the previous section: Azure Active Directory Username and Password.

    Interactive mode requires a password to be manually entered, or for accounts with multi-factor authentication enabled, complete your configured MFA authentication method.

    bcp bcptest out "c:lastdata1.dat" -c -t -S aadserver.database.windows.net -d testdb -G -U alice@aadtest.onmicrosoft.com

    In case an Azure AD user is a domain federated one using Windows account, the user name required in the command line, contains its domain account (for example, joe@contoso.com see below):

    bcp bcptest out "c:lastdata1.dat" -c -t -S aadserver.database.windows.net -d testdb -G -U joe@contoso.com

    If guest users exist in a specific Azure AD and are part of a group that exists in SQL Database that has database permissions to execute the bcp command, their guest user alias is used (for example, keith0@adventureworks.com).

-h «load hints[ ,… n]«
Specifies the hint or hints to be used during a bulk import of data into a table or view.

  • ORDER(column[ASC | DESC] [,n])
    The sort order of the data in the data file. Bulk import performance is improved if the data being imported is sorted according to the clustered index on the table, if any. If the data file is sorted in a different order, that is other than the order of a clustered index key, or if there is no clustered index on the table, the ORDER clause is ignored. The column names supplied must be valid column names in the destination table. By default, bcp assumes the data file is unordered. For optimized bulk import, [!INCLUDEssNoVersion] also validates that the imported data is sorted.

  • ROWS_PER_BATCH = bb
    Number of rows of data per batch (as bb). Used when -b is not specified, resulting in the entire data file being sent to the server as a single transaction. The server optimizes the bulkload according to the value bb. By default, ROWS_PER_BATCH is unknown.

  • KILOBYTES_PER_BATCH = cc
    Approximate number of kilobytes of data per batch (as cc). By default, KILOBYTES_PER_BATCH is unknown.

  • TABLOCK
    Specifies that a bulk update table-level lock is acquired for the duration of the bulkload operation; otherwise, a row-level lock is acquired. This hint significantly improves performance because holding a lock for the duration of the bulk-copy operation reduces lock contention on the table. A table can be loaded concurrently by multiple clients if the table has no indexes and TABLOCK is specified. By default, locking behavior is determined by the table option table lock on bulkload.

    [!NOTE]
    If the target table is clustered columnstore index, TABLOCK hint is not required for loading by multiple concurrent clients because each concurrent thread is assigned a separate rowgroup within the index and loads data into it. Please refer to columnstore index conceptual topics for details,

    CHECK_CONSTRAINTS
    Specifies that all constraints on the target table or view must be checked during the bulk-import operation. Without the CHECK_CONSTRAINTS hint, any CHECK, and FOREIGN KEY constraints are ignored, and after the operation the constraint on the table is marked as not-trusted.

    [!NOTE]
    UNIQUE, PRIMARY KEY, and NOT NULL constraints are always enforced.

    At some point, you will need to check the constraints on the entire table. If the table was nonempty before the bulk import operation, the cost of revalidating the constraint may exceed the cost of applying CHECK constraints to the incremental data. Therefore, we recommend that normally you enable constraint checking during an incremental bulk import.

    A situation in which you might want constraints disabled (the default behavior) is if the input data contains rows that violate constraints. With CHECK constraints disabled, you can import the data and then use [!INCLUDEtsql] statements to remove data that is not valid.

    [!NOTE]
    bcp now enforces data validation and data checks that might cause scripts to fail if they’re executed on invalid data in a data file.

    [!NOTE]
    The -m max_errors switch does not apply to constraint checking.

  • FIRE_TRIGGERS
    Specified with the in argument, any insert triggers defined on the destination table will run during the bulk-copy operation. If FIRE_TRIGGERS is not specified, no insert triggers will run. FIRE_TRIGGERS is ignored for the out, queryout, and format arguments.

-i input_file
Specifies the name of a response file, containing the responses to the command prompt questions for each data field when a bulk copy is being performed using interactive mode (-n, -c, -w, or -N not specified).

If input_file begins with a hyphen (-) or a forward slash (/), do not include a space between -i and the input_file value.

-k
Specifies that empty columns should retain a null value during the operation, rather than have any default values for the columns inserted. For more information, see Keep Nulls or Use Default Values During Bulk Import (SQL Server).

-K application_intent
Declares the application workload type when connecting to a server. The only value that is possible is ReadOnly. If -K is not specified, the bcp utility will not support connectivity to a secondary replica in an Always On availability group. For more information, see Active Secondaries: Readable Secondary Replicas (Always On Availability Groups).

-l login_timeout
Specifies a login timeout. The -l option specifies the number of seconds before a login to SQL Server times out when you try to connect to a server. The default login timeout is 15 seconds. The login timeout must be a number between 0 and 65534. If the value supplied is not numeric or does not fall into that range, bcp generates an error message. A value of 0 specifies an infinite timeout.

-L last_row
Specifies the number of the last row to export from a table or import from a data file. This parameter requires a value greater than (>) 0 but less than (<) or equal to (=) the number of the last row. In the absence of this parameter, the default is the last row of the file.

last_row can be a positive integer with a value up to 2^63-1.

-m max_errors
Specifies the maximum number of syntax errors that can occur before the bcp operation is canceled. A syntax error implies a data conversion error to the target data type. The max_errors total excludes any errors that can be detected only at the server, such as constraint violations.

A row that cannot be copied by the bcp utility is ignored and is counted as one error. If this option is not included, the default is 10.

[!NOTE]
The -m option also does not apply to converting the money or bigint data types.

-n
Performs the bulk-copy operation using the native (database) data types of the data. This option does not prompt for each field; it uses the native values.

For more information, see Use Native Format to Import or Export Data (SQL Server).

-N
Performs the bulk-copy operation using the native (database) data types of the data for noncharacter data, and Unicode characters for character data. This option offers a higher performance alternative to the -w option, and is intended for transferring data from one instance of [!INCLUDEssNoVersion] to another using a data file. It does not prompt for each field. Use this option when you are transferring data that contains ANSI extended characters and you want to take advantage of the performance of native mode.

For more information, see Use Unicode Native Format to Import or Export Data (SQL Server).

If you export and then import data to the same table schema by using bcp.exe with -N, you might see a truncation warning if there is a fixed length, non-Unicode character column (for example, char(10)).

The warning can be ignored. One way to resolve this warning is to use -n instead of -N.

-o output_file
Specifies the name of a file that receives output redirected from the command prompt.

If output_file begins with a hyphen (-) or a forward slash (/), do not include a space between -o and the output_file value.

-P password
Specifies the password for the login ID. If this option is not used, the bcp command prompts for a password. If this option is used at the end of the command prompt without a password, bcp uses the default password (NULL).

[!IMPORTANT]
[!INCLUDEssNoteStrongPass]

To mask your password, do not specify the -P option along with the -U option. Instead, after specifying bcp along with the -U option and other switches (do not specify -P), press ENTER, and the command will prompt you for a password. This method ensures that your password will be masked when it is entered.

If password begins with a hyphen (-) or a forward slash (/), do not add a space between -P and the password value.

-q
Executes the SET QUOTED_IDENTIFIERS ON statement in the connection between the bcp utility and an instance of [!INCLUDEssNoVersion]. Use this option to specify a database, owner, table, or view name that contains a space or a single quotation mark. Enclose the entire three-part table or view name in quotation marks («»).

To specify a database name that contains a space or single quotation mark, you must use the -q option.

-q does not apply to values passed to -d.

For more information, see Remarks, later in this topic.

-r row_term
Specifies the row terminator. The default is n (newline character). Use this parameter to override the default row terminator. For more information, see Specify Field and Row Terminators (SQL Server).

If you specify the row terminator in hexadecimal notation in a bcp.exe command, the value will be truncated at 0x00. For example, if you specify 0x410041, 0x41 will be used.

If row_term begins with a hyphen (-) or a forward slash (/), do not include a space between -r and the row_term value.

-R
Specifies that currency, date, and time data is bulk copied into [!INCLUDEssNoVersion] using the regional format defined for the locale setting of the client computer. By default, regional settings are ignored.

-S server_name [instance_name]
Specifies the instance of [!INCLUDEssNoVersion] to which to connect. If no server is specified, the bcp utility connects to the default instance of [!INCLUDEssNoVersion] on the local computer. This option is required when a bcp command is run from a remote computer on the network or a local named instance. To connect to the default instance of [!INCLUDEssNoVersion] on a server, specify only server_name. To connect to a named instance of [!INCLUDEssNoVersion], specify server_nameinstance_name.

-t field_term
Specifies the field terminator. The default is t (tab character). Use this parameter to override the default field terminator. For more information, see Specify Field and Row Terminators (SQL Server).

If you specify the field terminator in hexadecimal notation in a bcp.exe command, the value will be truncated at 0x00. For example, if you specify 0x410041, 0x41 will be used.

If field_term begins with a hyphen (-) or a forward slash (/), do not include a space between -t and the field_term value.

-T
Specifies that the bcp utility connects to [!INCLUDEssNoVersion] with a trusted connection using integrated security. The security credentials of the network user, login_id, and password are not required. If -T is not specified, you need to specify -U and -P to successfully log in.

[!IMPORTANT]
When the bcp utility is connecting to [!INCLUDEssNoVersion] with a trusted connection using integrated security, use the -T option (trusted connection) instead of the user name and password combination. When the bcp utility is connecting to SQL Database or Azure Synapse Analytics, using Windows authentication or Azure Active Directory authentication is not supported. Use the -U and -P options.

-U login_id
Specifies the login ID used to connect to [!INCLUDEssNoVersion].

[!IMPORTANT]
When the bcp utility is connecting to [!INCLUDEssNoVersion] with a trusted connection using integrated security, use the -T option (trusted connection) instead of the user name and password combination. When the bcp utility is connecting to SQL Database or Azure Synapse Analytics, using Windows authentication or Azure Active Directory authentication is not supported. Use the -U and -P options.

-v
Reports the bcp utility version number and copyright.

-V (80 | 90 | 100 | 110 | 120 | 130)
Performs the bulk-copy operation using data types from an earlier version of [!INCLUDEssNoVersion]. This option does not prompt for each field; it uses the default values.

80 = [!INCLUDEssVersion2000]

90 = [!INCLUDEssVersion2005]

100 = [!INCLUDEsql2008-md] and [!INCLUDEsql2008r2]

110 = [!INCLUDEssSQL11]

120 = [!INCLUDEssSQL14]

130 = [!INCLUDEsssql15-md]

For example, to generate data for types not supported by [!INCLUDEssVersion2000], but were introduced in later versions of [!INCLUDEssNoVersion], use the -V80 option.

For more information, see Import Native and Character Format Data from Earlier Versions of SQL Server.

-w
Performs the bulk copy operation using Unicode characters. This option does not prompt for each field; it uses nchar as the storage type, no prefixes, t (tab character) as the field separator, and n (newline character) as the row terminator. -w is not compatible with -c.

For more information, see Use Unicode Character Format to Import or Export Data (SQL Server).

-x
Used with the format and -f format_file options, generates an XML-based format file instead of the default non-XML format file. The -x does not work when importing or exporting data. It generates an error if used without both format and -f format_file.

Remarks

  • The bcp 13.0 client is installed when you install [!INCLUDEmsCoName] [!INCLUDEsssql19-md.md] tools. If tools are installed for multiple versions of [!INCLUDEssNoVersion], depending on the order of values of the PATH environment variable, you might be using the earlier bcp client instead of the bcp 13.0 client. This environment variable defines the set of directories used by Windows to search for executable files. To discover which version you are using, run the bcp /v or bcp -v command at the Windows Command Prompt. For information about how to set the command path in the PATH environment variable, see Environment Variables or search for Environment Variables in Windows Help.

    To make sure the newest version of the bcp utility is running you need to remove any older versions of the bcp utility.

    To determine where all versions of the bcp utility are installed, type in the command prompt:

  • The bcp utility can also be downloaded separately from the Microsoft SQL Server 2016 Feature Pack. Select either ENUx64MsSqlCmdLnUtils.msi or ENUx86MsSqlCmdLnUtils.msi.

  • XML format files are only supported when [!INCLUDEssNoVersion] tools are installed together with [!INCLUDEssNoVersion] Native Client.

  • For information about where to find or how to run the bcp utility and about the command prompt utilities syntax conventions, see Command Prompt Utility Reference (Database Engine).

  • For information on preparing data for bulk import or export operations, see Prepare Data for Bulk Export or Import (SQL Server).

  • For information about when row-insert operations that are performed by bulk import are logged in the transaction log, see Prerequisites for Minimal Logging in Bulk Import.

  • Using additional special characters

    The characters <, >, |, &, ^ are special command shell characters, and they must be preceded by the escape character (^) or enclosed in quotation marks when used in String (for example, «StringContaining&Symbol»). If you use quotation marks to enclose a string that contains one of the special characters, the quotation marks are set as part of the environment variable value.

Native Data File Support

In [!INCLUDEssnoversion], the bcp utility supports native data files compatible with [!INCLUDEssNoVersion] versions starting with [!INCLUDEssVersion2000] and later.

Computed Columns and timestamp Columns

Values in the data file being imported for computed or timestamp columns are ignored, and [!INCLUDEssNoVersion] automatically assigns values. If the data file does not contain values for the computed or timestamp columns in the table, use a format file to specify that the computed or timestamp columns in the table should be skipped when importing data; [!INCLUDEssNoVersion] automatically assigns values for the column.

Computed and timestamp columns are bulk copied from [!INCLUDEssNoVersion] to a data file as usual.

Specifying Identifiers That Contain Spaces or Quotation Marks

[!INCLUDEssNoVersion] identifiers can include characters such as embedded spaces and quotation marks. Such identifiers must be treated as follows:

  • When you specify an identifier or file name that includes a space or quotation mark at the command prompt, enclose the identifier in quotation marks («»).

    For example, the following bcp out command creates a data file named Currency Types.dat:

    bcp AdventureWorks2012.Sales.Currency out "Currency Types.dat" -T -c  
  • To specify a database name that contains a space or quotation mark, you must use the -q option.

  • For owner, table, or view names that contain embedded spaces or quotation marks, you can either:

    • Specify the -q option, or

    • Enclose the owner, table, or view name in brackets ([]) inside the quotation marks.

Data Validation

bcp now enforces data validation and data checks that might cause scripts to fail if they’re executed on invalid data in a data file. For example, bcp now verifies that:

  • The native representations of float or real data types are valid.

  • Unicode data has an even-byte length.

Forms of invalid data that could be bulk imported in earlier versions of [!INCLUDEssNoVersion] might fail to load now; whereas, in earlier versions, the failure did not occur until a client tried to access the invalid data. The added validation minimizes surprises when querying the data after bulkload.

Bulk Exporting or Importing SQLXML Documents

To bulk export or import SQLXML data, use one of the following data types in your format file.

Data type Effect
SQLCHAR or SQLVARYCHAR The data is sent in the client code page or in the code page implied by the collation). The effect is the same as specifying the -c switch without specifying a format file.
SQLNCHAR or SQLNVARCHAR The data is sent as Unicode. The effect is the same as specifying the -w switch without specifying a format file.
SQLBINARY or SQLVARYBIN The data is sent without any conversion.

Permissions

A bcp out operation requires SELECT permission on the source table.

A bcp in operation minimally requires SELECT/INSERT permissions on the target table. In addition, ALTER TABLE permission is required if any of the following is true:

  • Constraints exist and the CHECK_CONSTRAINTS hint is not specified.

    [!NOTE]
    Disabling constraints is the default behavior. To enable constraints explicitly, use the -h option with the CHECK_CONSTRAINTS hint.

  • Triggers exist and the FIRE_TRIGGER hint is not specified.

    [!NOTE]
    By default, triggers are not fired. To fire triggers explicitly, use the -h option with the FIRE_TRIGGERS hint.

  • You use the -E option to import identity values from a data file.

[!NOTE]
Requiring ALTER TABLE permission on the target table was new in [!INCLUDEssVersion2005]. This new requirement might cause bcp scripts that do not enforce triggers and constraint checks to fail if the user account lacks ALTER table permissions for the target table.

Character Mode (-c) and Native Mode (-n) Best Practices

This section has recommendations for to character mode (-c) and native mode (-n).

  • (Administrator/User) When possible, use native format (-n) to avoid the separator issue. Use the native format to export and import using [!INCLUDEssNoVersion]. Export data from [!INCLUDEssNoVersion] using the -c or -w option if the data will be imported to a non-[!INCLUDEssNoVersion] database.

  • (Administrator) Verify data when using BCP OUT. For example, when you use BCP OUT, BCP IN, and then BCP OUT verify that the data is properly exported and the terminator values are not used as part of some data value. Consider overriding the default terminators (using -t and -r options) with random hexadecimal values to avoid conflicts between terminator values and data values.

  • (User) Use a long and unique terminator (any sequence of bytes or characters) to minimize the possibility of a conflict with the actual string value. This can be done by using the -t and -r options.

Examples

This section contains the following examples:

A. Identify bcp utility version

B. Copying table rows into a data file (with a trusted connection)

C. Copying table rows into a data file (with Mixed-mode Authentication)

D. Copying data from a file to a table

E. Copying a specific column into a data file

F. Copying a specific row into a data file

G. Copying data from a query to a data file

H. Creating format files

I. Using a format file to bulk import with bcp

J. Specifying a code page

Example Test Conditions

The examples below make use of the WideWorldImporters sample database for SQL Server (starting 2016) and Azure SQL Database. WideWorldImporters can be downloaded from https://github.com/Microsoft/sql-server-samples/releases/tag/wide-world-importers-v1.0. See RESTORE (Transact-SQL) for the syntax to restore the sample database. Except where specified otherwise, the examples assume that you are using Windows Authentication and have a trusted connection to the server instance on which you are running the bcp command. A directory named D:BCP will be used in many of the examples.

The script below creates an empty copy of the WideWorldImporters.Warehouse.StockItemTransactions table and then adds a primary key constraint. Run the following T-SQL script in SQL Server Management Studio (SSMS)

USE WideWorldImporters;  
GO  

SET NOCOUNT ON;

IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'Warehouse.StockItemTransactions_bcp')
BEGIN
    SELECT * INTO WideWorldImporters.Warehouse.StockItemTransactions_bcp
    FROM WideWorldImporters.Warehouse.StockItemTransactions  
    WHERE 1 = 2;  

    ALTER TABLE Warehouse.StockItemTransactions_bcp 
    ADD CONSTRAINT PK_Warehouse_StockItemTransactions_bcp PRIMARY KEY NONCLUSTERED 
    (StockItemTransactionID ASC);
END

[!NOTE]
Truncate the StockItemTransactions_bcp table as needed.

TRUNCATE TABLE WideWorldImporters.Warehouse.StockItemTransactions_bcp;

A. Identify bcp utility version

At a command prompt, enter the following command:

B. Copying table rows into a data file (with a trusted connection)

The following examples illustrate the out option on the WideWorldImporters.Warehouse.StockItemTransactions table.

  • Basic
    This example creates a data file named StockItemTransactions_character.bcp and copies the table data into it using character format.

    At a command prompt, enter the following command:

    bcp WideWorldImporters.Warehouse.StockItemTransactions out D:BCPStockItemTransactions_character.bcp -c -T
  • Expanded
    This example creates a data file named StockItemTransactions_native.bcp and copies the table data into it using the native format. The example also: specifies the maximum number of syntax errors, an error file, and an output file.

    At a command prompt, enter the following command:

    bcp WideWorldImporters.Warehouse.StockItemTransactions OUT D:BCPStockItemTransactions_native.bcp -m 1 -n -e D:BCPError_out.log -o D:BCPOutput_out.log -S -T

Review Error_out.log and Output_out.log. Error_out.log should be blank. Compare the file sizes between StockItemTransactions_character.bcp and StockItemTransactions_native.bcp.

C. Copying table rows into a data file (with mixed-mode authentication)

The following example illustrates the out option on the WideWorldImporters.Warehouse.StockItemTransactions table. This example creates a data file named StockItemTransactions_character.bcp and copies the table data into it using character format.

The example assumes that you are using mixed-mode authentication, you must use the -U switch to specify your login ID. Also, unless you are connecting to the default instance of [!INCLUDEssNoVersion] on the local computer, use the -S switch to specify the system name and, optionally, an instance name.

At a command prompt, enter the following command: (The system will prompt you for your password.)

bcp WideWorldImporters.Warehouse.StockItemTransactions out D:BCPStockItemTransactions_character.bcp -c -U<login_id> -S<server_nameinstance_name>

D. Copying data from a file to a table

The following examples illustrate the in option on the WideWorldImporters.Warehouse.StockItemTransactions_bcp table using files created above.

  • Basic
    This example uses the StockItemTransactions_character.bcp data file previously created.

    At a command prompt, enter the following command:

    bcp WideWorldImporters.Warehouse.StockItemTransactions_bcp IN D:BCPStockItemTransactions_character.bcp -c -T
  • Expanded
    This example uses the StockItemTransactions_native.bcp data file previously created. The example also: use the hint TABLOCK, specifies the batch size, the maximum number of syntax errors, an error file, and an output file.

At a command prompt, enter the following command:

bcp WideWorldImporters.Warehouse.StockItemTransactions_bcp IN D:BCPStockItemTransactions_native.bcp -b 5000 -h "TABLOCK" -m 1 -n -e D:BCPError_in.log -o D:BCPOutput_in.log -S -T

Review Error_in.log and Output_in.log.

E. Copying a specific column into a data file

To copy a specific column, you can use the queryout option. The following example copies only the StockItemTransactionID column of the Warehouse.StockItemTransactions table into a data file.

At a command prompt, enter the following command:

bcp "SELECT StockItemTransactionID FROM WideWorldImporters.Warehouse.StockItemTransactions WITH (NOLOCK)" queryout D:BCPStockItemTransactionID_c.bcp -c -T

F. Copying a specific row into a data file

To copy a specific row, you can use the queryout option. The following example copies only the row for the person named Amy Trefl from the WideWorldImporters.Application.People table into a data file Amy_Trefl_c.bcp. Note: the -d switch is used identify the database.

At a command prompt, enter the following command:

bcp "SELECT * from Application.People WHERE FullName = 'Amy Trefl'" queryout D:BCPAmy_Trefl_c.bcp -d WideWorldImporters -c -T

G. Copying data from a query to a data file

To copy the result set from a Transact-SQL statement to a data file, use the queryout option. The following example copies the names from the WideWorldImporters.Application.People table, ordered by full name, into the People.txt data file. Note: the -t switch is used to create a comma-delimited file.

At a command prompt, enter the following command:

bcp "SELECT FullName, PreferredName FROM WideWorldImporters.Application.People ORDER BY FullName" queryout D:BCPPeople.txt -t, -c -T

H. Creating format files

The following example creates three different format files for the Warehouse.StockItemTransactions table in the WideWorldImporters database. Review the contents of each created file.

At a command prompt, enter the following commands:

REM non-XML character format
bcp WideWorldImporters.Warehouse.StockItemTransactions format nul -f D:BCPStockItemTransactions_c.fmt -c -T 

REM non-XML native format
bcp WideWorldImporters.Warehouse.StockItemTransactions format nul -f D:BCPStockItemTransactions_n.fmt -n -T

REM XML character format
bcp WideWorldImporters.Warehouse.StockItemTransactions format nul -f D:BCPStockItemTransactions_c.xml -x -c -T

[!NOTE]
To use the -x switch, you must be using a bcp 9.0 client. For information about how to use the bcp 9.0 client, see «Remarks.»

For more information, see Non-XML Format Files (SQL Server) and XML Format Files (SQL Server).

I. Using a format file to bulk import with bcp

To use a previously created format file when importing data into an instance of [!INCLUDEssNoVersion], use the -f switch with the in option. For example, the following command bulk copies the contents of a data file, StockItemTransactions_character.bcp, into a copy of the Warehouse.StockItemTransactions_bcp table by using the previously created format file, StockItemTransactions_c.xml. Note: the -L switch is used to import only the first 100 records.

At a command prompt, enter the following command:

bcp WideWorldImporters.Warehouse.StockItemTransactions_bcp in D:BCPStockItemTransactions_character.bcp -L 100 -f D:BCPStockItemTransactions_c.xml -T

[!NOTE]
Format files are useful when the data file fields are different from the table columns; for example, in their number, ordering, or data types. For more information, see Format Files for Importing or Exporting Data (SQL Server).

J. Specifying a code page

The following partial code example shows bcp import while specifying a code page 65001:

bcp.exe MyTable in "D:data.csv" -T -c -C 65001 -t , ...  

Additional Examples

The following topics contain examples of using bcp:
Data Formats for Bulk Import or Bulk Export (SQL Server)
 ● Use Native Format to Import or Export Data (SQL Server)
 ● Use Character Format to Import or Export Data (SQL Server)
 ● Use Unicode Native Format to Import or Export Data (SQL Server)
 ● Use Unicode Character Format to Import or Export Data (SQL Server)

Specify Field and Row Terminators (SQL Server)

Keep Nulls or Use Default Values During Bulk Import (SQL Server)

Keep Identity Values When Bulk Importing Data (SQL Server)

Format Files for Importing or Exporting Data (SQL Server))
 ● Create a Format File (SQL Server)
 ● Use a Format File to Bulk Import Data (SQL Server)
 ● Use a Format File to Skip a Table Column (SQL Server)
 ● Use a Format File to Skip a Data Field (SQL Server)
 ● Use a Format File to Map Table Columns to Data-File Fields (SQL Server)

Examples of Bulk Import and Export of XML Documents (SQL Server)

Considerations and limitations

  • The bcp utility has a limitation that the error message shows only 512-byte characters. Only the first 512 bytes of the error message are displayed.

Next steps

  • Prepare Data for Bulk Export or Import (SQL Server)
  • BULK INSERT (Transact-SQL)
  • OPENROWSET (Transact-SQL)
  • SET QUOTED_IDENTIFIER (Transact-SQL)
  • sp_configure (Transact-SQL)
  • sp_tableoption (Transact-SQL)
  • Format Files for Importing or Exporting Data (SQL Server)

[!INCLUDEget-help-options]

2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

1

Ошибка при экспорте данных

12.02.2015, 01:12. Показов 2304. Ответов 19


ребятушки, такая трабл, пытаюсь экспортнуть данные одной таблицы, выдает ошибку как на первой скрине
поискал что это за ошибка такая, пишут, что нужно запустить браузер, пытаюсь запустить с помощью незамысловатой команды и выдает ошибку
помогите пожалуйста!

Миниатюры

Ошибка при экспорте данных
 

Ошибка при экспорте данных
 

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

12.02.2015, 11:32

 [ТС]

3

invm,

you shouldn’t use MSSQLSERVER

вот еще одна проблемка в том, что у меня нет его в этом списке
как быть, помогите?

Миниатюры

Ошибка при экспорте данных
 



0



3318 / 2027 / 723

Регистрация: 02.06.2013

Сообщений: 4,976

12.02.2015, 12:16

4

Лучший ответ Сообщение было отмечено RayPas как решение

Решение

Цитата
Сообщение от RayPas
Посмотреть сообщение

как быть, помогите?

Чтобы указать имя сервера, у bcp есть ключ -S.
У вас именованный экземпляр, поэтому нужно или -S .SQLEXPRESS, если идем к локальному серверу, или
-S СерверSQLEXPRESS, если к удаленному.



1



2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

12.02.2015, 12:24

 [ТС]

5

invm, спасибо огромное!



0



2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

12.02.2015, 12:27

 [ТС]

6

invm, теперь почему-то проблема с копированием началась…

Миниатюры

Ошибка при экспорте данных
 



0



3318 / 2027 / 723

Регистрация: 02.06.2013

Сообщений: 4,976

12.02.2015, 12:45

7

RayPas, у вас в первоначальном посте выгрузка. Откуда загрузка взялась?



0



2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

12.02.2015, 12:54

 [ТС]

8

invm, хмм, он о выгрузке и пишет, там в конце написано Ошибка bcp-копирования out



0



3318 / 2027 / 723

Регистрация: 02.06.2013

Сообщений: 4,976

12.02.2015, 13:39

9

Зачем -x при out?
Не указан выходной файл после out.



0



2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

12.02.2015, 13:55

 [ТС]

10

invm, скопировалось, а куда — не пойму…

Миниатюры

Ошибка при экспорте данных
 



0



3318 / 2027 / 723

Регистрация: 02.06.2013

Сообщений: 4,976

12.02.2015, 14:00

11

RayPas, ну так вы же указали файл после out. Вот в него и выгрузилось.



1



2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

12.02.2015, 14:03

 [ТС]

12

invm, всё получилось!) вопрос пока снят) спасибо еще раз за помощь!



0



2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

22.02.2015, 22:46

 [ТС]

13

invm, падаю ниц и прошу помощи еще в таком деле
Оба файла нормально просматриваются в нот паде, но вот импорт ни в какую…читал что могут быть проблемы с тем что тип данных nvarchar…но как исправить ошибку нету нигде…

Миниатюры

Ошибка при экспорте данных
 



0



3318 / 2027 / 723

Регистрация: 02.06.2013

Сообщений: 4,976

22.02.2015, 23:30

14

RayPas, не видя содержимое файла данных и форматфайла, трудно что-либо посоветовать.



0



2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

22.02.2015, 23:50

 [ТС]

15

invm, вот, пожалуйста

Миниатюры

Ошибка при экспорте данных
 

Ошибка при экспорте данных
 



0



3318 / 2027 / 723

Регистрация: 02.06.2013

Сообщений: 4,976

23.02.2015, 00:14

16

RayPas, у вас форматфайл с ошибками. Как должно быть смотрите тут.



1



2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

23.02.2015, 11:12

 [ТС]

17

invm, исправил, теперь выглядит как там, но ошибка та же..(



0



2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

23.02.2015, 11:18

 [ТС]

18

invm, вот пересоздал все таким образом, с примеров на msdn а ошибки те же

Миниатюры

Ошибка при экспорте данных
 



0



3318 / 2027 / 723

Регистрация: 02.06.2013

Сообщений: 4,976

23.02.2015, 12:49

19

RayPas, вы поставили разделителем полей «;», а в файле у вас явно табуляция.



1



2 / 0 / 0

Регистрация: 18.01.2013

Сообщений: 370

23.02.2015, 12:55

 [ТС]

20

invm, сработало! снова — большое спасибо Вам)



0



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

23.02.2015, 12:55

20

Понравилась статья? Поделить с друзьями:
  • Explorer syntax error
  • Explorer exe системное предупреждение unknown hard error windows 10
  • Explorer exe ошибка файловой системы 2147219200
  • Explorer exe ошибка файловой системы 2018374635
  • Explorer exe ошибка приложения как исправить