为什么 SQL Server 不处理此代码不稳定? [英] Why SQL Server doesn't treat this code erratic?
问题描述
这实际上不是我面临的问题.但我只是想知道第一个由于列列表末尾有多余的逗号 (,),因此 SQL Server 应将下面编写的代码中的行视为语法错误.但它运行代码很好.有人知道原因吗?
It not actually a problem that i'm facing. But i'm just wondering that the first line in the code written below should be treated as a syntax error by SQL Server because of the extra comma (,) in the end of columns list. But it runs the code fine. Does anyone know the reason?
CREATE TABLE #TEMP(COL1 INT,COL2 VARCHAR,)
INSERT INTO #TEMP VALUES (1,'A')
SELECT * FROM #TEMP
DROP TABLE #TEMP
推荐答案
它应该被标记为语法错误,但是 SQL Server 中存在一个错误,它不会将尾随逗号视为语法错误.
It should be flagged as a syntax error, but there is a bug in SQL Server that doesn't treat the trailing comma as a syntax error.
来源:Microsoft 支持(列表中受影响的版本 - 6、6.5 和 2000- 很旧,但我想它仍然存在,因为它在 2008 年才对我有用.)
Source: Microsoft Support (The affected versions in the list - 6, 6.5, and 2000 - are old, but I guess it's still around because it just worked for me in 2008.)
这篇关于为什么 SQL Server 不处理此代码不稳定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!