mercredi 30 septembre 2015

SSMS 2014 - Cannot insert multiple values into table variable

This is probably something really trivial I'm missing, but I can't seem to figure out why it's not working:

Basically, this works:

DECLARE @names TABLE (name NVARCHAR(100))
;
INSERT INTO @names
VALUES
    ('John')
;

but this does not:

DECLARE @names TABLE (name NVARCHAR(100))
;
INSERT INTO @names
VALUES
    ('John'),
    ('Jane')
;

I'm getting this error:

Msg 102, Level 15, State 1, Line 5

Incorrect syntax near ','.

Why wouldn't this work? I've done this thousands of times with SSMS 2008.

Aucun commentaire:

Enregistrer un commentaire