3

I want to put this on the SQL fiddle site for another company that I am working for and it seems that it does not like my syntax. The site uses the SQL Server syntax so I am curious as to why this will not work.

The create table code does work correctly. It is the insert data into the table that is cause the so called glitch.

I am in the process of learning SQL and how to use the SQLFiddle Site. This is code that I am using to see if I can make the SQLFiddle site build the database so that I can test it with different SQL query statements.

Question: Why is this code not compiling and running on the SQL Fiddle Site?

Code

CREATE TABLE myTable (ID  integer     null,
                      AAA varchar(20) null,
                      BBB varchar(40) null,
                      CCC varchar(40) null,
                      DDD varchar(40) null);

INSERT INTO myTable (ID, 
                     AAA, 
                     BBB, 
                     CCC,
                     DDD)
       VALUES  (1,
               'Tom B. Erichsen',
               'Skagen 21',
               'Stavanger',
               '4006'),

               (2,
               'Tom B. Erichsen',
               'Skagen 21',
               'Stavanger',
               '4008'); 

Added the missing semi-colon. Even though that this is a simple type-o I think that it shows that even simple things in programming can cause bigger problems than you would think.

Doug Hauf
  • 3,025
  • 8
  • 46
  • 70
  • 3
    I think that this is a descent question. Even thought it is a simple semi-colon not in the correct spot. That would be expected since he is just learning to use the SQL Fiddle site. – user3491862 May 01 '14 at 14:44
  • @user3491862 It was closed not because it's a bad question, but because it was answered already and not something likely to help anyone else. That's exactly what the vote close reason says. It's not any sort of penalty. –  May 01 '14 at 15:24
  • That said, I think the answer here is wrong. The syntax is valid for SQL Server, which doesn't require the semicolon. More likely, the OP is using SQL Fiddle with MySQL, instead of SQL Server. –  May 01 '14 at 15:27
  • SqlFiddle allows you to change the batch delimiter sequence for all RDBMs. For a strange reason, the default set by SqlFiddle *is* the semicolon, which will mean even even SqlServer will work with a script like the above, although obviously this isn't a good idea if you are accustomed to using ANSI semi colons as the statement terminator ... – StuartLC May 09 '14 at 05:01

1 Answers1

4

You forgot the semi-colon after your CREATE statement (before INSERT).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335