zoukankan      html  css  js  c++  java
  • String or binary data would be truncated. The statement has been terminated.

    SET ANSI_WARNINGS (Transact-SQL)

    https://docs.microsoft.com/en-us/sql/t-sql/statements/set-ansi-warnings-transact-sql

    The SQL Server Native Client ODBC driver and SQL Server Native Client OLE DB Provider for SQL Server automatically set ANSI_WARNINGS to ON when connecting. This can be configured in ODBC data sources, in ODBC connection attributes, set in the application before connecting. The default for SET ANSI_WARNINGS is OFF for connections from DB-Library applications.

    ODBC

    https://support.office.com/en-us/article/Administer-ODBC-data-sources-b19f856b-5b9b-48c9-8b93-07484bfab5a7

    Add an ODBC data source

    Before proceeding, obtain and install the appropriate ODBC driver for the data source to which you want to connect.

    NOTE:  You must be a member of the Administrators group on your local machine in order to add or configure an ODBC data source.

    1. Click Start, and then click Control Panel.

    2. In the Control Panel, double-click Administrative Tools.

    3. In the Administrative Tools dialog box, double-click Data Sources (ODBC).

      The ODBC Data Source Administrator dialog box appears.

    4. Click User DSN, System DSN, or File DSN, depending on the type of data source you want to add. For more information, see the section About ODBC data sources.

    5. Click Add.

    6. Select the driver that you want to use, and then click Finish or Next.

      If the driver you want is not listed, contact the administrator of the database you are connecting to for information about how to obtain the correct driver.

    7. Follow the instructions and enter the required connection information in any dialog boxes that follow.

    Click Help in the ODBC dialog boxes for more information about the individual settings.

     

     

    DECLARE @MyTable TABLE
        (
            RowNumber INT NOT NULL ,
            DatabaseName NVARCHAR(50) NOT NULL ,
            DBOwner NVARCHAR(10) NOT NULL
        );
    INSERT INTO @MyTable ( RowNumber ,
                           DatabaseName ,
                           DBOwner )
                SELECT ROW_NUMBER() OVER ( ORDER BY name )  ,
                       name  ,
                       SUSER_SNAME(owner_sid) 
                FROM   sys.databases
                WHERE  SUSER_SNAME(owner_sid) <> 'sa'

    原因:因为有一部分DBOwner的字符串长度超过10了,所以,可以考虑使用nvarchar(max)

     

     

     

  • 相关阅读:
    linux 11201(11203) ASM RAC 安装
    [学习笔记]多项式对数函数
    linux 10201 ASM RAC 安装+升级到10205
    tar
    [学习笔记]多项式开根
    gzip
    小朋友和二叉树
    zip
    bzoj5016 一个简单的询问
    unzip
  • 原文地址:https://www.cnblogs.com/chucklu/p/7484978.html
Copyright © 2011-2022 走看看