我在AWS RDS SQL Server数据库中遇到了一个奇怪的问题,我已经开始旋转,但我无法弄清楚发生了什么。
测试1
create table #tmp
(test varchar(10) null)
insert into #tmp
select 'asfsadfasdsafdafas'
select * from #tmp
drop table #tmp
结果:
Msg 8152,Level 16,State 14,Line 5
字符串或二进制数据将被截断。(0行(s)受影响)
测试2
set ANSI_WARNINGS OFF
create table #tmp1
(test varchar(10) null)
insert into #tmp1
select 'asfsadfasdsafdafas'
select * from #tmp1
drop table #tmp1
结果:
------------------
asfsadfasd
当我查看数据库属性时,它表示ANSI Warnings Enabled设置为FALSE,但是,数据库似乎没有按预期运行。
任何帮助都将不胜感激。
修改 另一个例子可能有帮助
ALTER DATABASE test_db
set QUOTED_IDENTIFIER OFF
go
select "hello"
结果:
Msg 207,Level 16,State 1,Line 5 列名称无效' hello'。
由于
答案 0 :(得分:0)
--The Issue Occur Because of Length Of Datatype
create table #tmp1
(test varchar(50) null)
insert into #tmp1
select 'asfsadfasdsafdafas'
select * from #tmp1
drop table #tmp1
--==============================
When create or alter SQL object like Stored Procedure, User Defined Function in Query Analyzer, it is created with following SQL commands prefixed and suffixed. What are these – QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF?
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO--SQL PROCEDURE, SQL FUNCTIONS, SQL OBJECTGO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
ANSI NULL ON/OFF:
This option specifies the setting for ANSI NULL comparisons. When this is on, any query that compares a value with a null returns a 0. When off, any query that compares a value with a null returns a null value.
QUOTED IDENTIFIER ON/OFF:
This options specifies the setting for usage of double quotation. When this is on, double quotation mark is used as part of the SQL Server identifier (object name). This can be useful in situations in which identifiers are also SQL Server reserved words.