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
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.
-
Click Start, and then click Control Panel.
-
In the Control Panel, double-click Administrative Tools.
-
In the Administrative Tools dialog box, double-click Data Sources (ODBC).
The ODBC Data Source Administrator dialog box appears.
-
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.
-
Click Add.
-
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.
-
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)
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2016-09-06 PowerShell 4 on win7 sp1
2016-09-06 about_Execution_Policies
2016-09-06 PowerShell常用命令
2016-09-06 Installing Chocolatey
2016-09-06 将NuGet配置到环境变量中
2015-09-06 XtraForm中OfficeSkins以及BonusSkin皮肤的设置
2015-09-06 XtraForm中更换皮肤