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
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.
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With