Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Need help building a table in SQLfiddle

so, I’m trying to create a small database/couple of tables in sqlfiddle using the ms sql server 2017 version. I always get "incorrect syntax near ‘123’". and, I’m not sure what the problem is. Please advise.

CREATE TABLE ProjectIpMapping (
projectId varchar(3),
ip varchar(12));

CREATE TABLE Requests (
sourceIp varchar(12),
destinationIp varchar(12),
projectId varchar(3),
requestId varchar(4),
sizeBits int);

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

INSERT into ProjectIpMapping (projectId, ip)
(123, 203.0.113.42),
(456, 203.2.56.112),
(165, 197.32.12.43),
(318, 197.32.45.18);

INSERT INTO Requests (sourceIp, destinationIp, projectId, requestId, sizeBits)
VALUES
(203.0.113.42, 197.32.45.18, 318, 1234, 11239),
(203.0.113.42, 326.22.15.19, 123, 1235, 1239),
(203.2.56.112, 197.32.45.18, 165, 1236, 12394),
(197.32.45.18, 326.22.15.19, 123, 1237, 2821),
(197.32.45.18, 821.54.03.20, 318, 1238, 234)

>Solution :

You are missing the VALUES keyword and you are declaring strings as VARCHAR type but you’re not enclosing inside quotes.

CREATE TABLE ProjectIpMapping ( 
    projectId varchar(3), 
    ip        varchar(12)
);

CREATE TABLE Requests ( 
    sourceIp        varchar(12), 
    destinationIp   varchar(12), 
    projectId       varchar(3), 
    requestId       varchar(4), 
    sizeBits        int
);

INSERT into ProjectIpMapping (projectId, ip) VALUES 
('123', '203.0.113.42'), 
('456', '203.2.56.112'), 
('165', '197.32.12.43'), 
('318', '197.32.45.18');

INSERT INTO Requests (sourceIp, destinationIp, projectId, requestId, sizeBits) VALUES 
('203.0.113.42', '197.32.45.18', '318', '1234', 11239), 
('203.0.113.42', '326.22.15.19', '123', '1235', 1239 ), 
('203.2.56.112', '197.32.45.18', '165', '1236', 12394), 
('197.32.45.18', '326.22.15.19', '123', '1237', 2821 ), 
('197.32.45.18', '821.54.03.20', '318', '1238', 234  );

Check the demo here.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading