sql server - Insérer plusieurs lignes dans une seule requête SQL

Mots clés : sqlsql-servertsqlinsert

meilleur 5 Réponses sql server - Insérer plusieurs lignes dans une seule requête SQL

vote vote

99

INSERT INTO MyTable ( Column1, Column2 ) VALUES ( Value1, Value2 ), ( Value1, Value2 ) 
INSERT INTO MyTable   ( Column1, Column2, Column3 ) VALUES   ('John', 123, 'Lloyds Office'),    ('Jane', 124, 'Lloyds Office'),    ('Billy', 125, 'London Office'),   ('Miranda', 126, 'Bristol Office'); 
vote vote

82

INSERT INTO table1 (First, Last) VALUES     ('Fred', 'Smith'),     ('John', 'Smith'),     ('Michael', 'Smith'),     ('Robert', 'Smith'); 
vote vote

79

INSERT INTO MyTable  (FirstCol, SecondCol)     SELECT  'First' ,1     UNION ALL SELECT  'Second' ,2     UNION ALL SELECT  'Third' ,3 ... 
vote vote

68

INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9); 
vote vote

58

del foo['bar'] 
>>> foo = {'bar': 'baz'} >>> fu = dict(foo) >>> del foo['bar'] >>> print foo {} >>> print fu {'bar': 'baz'} 
def minus_key(key, dictionary):     shallow_copy = dict(dictionary)     del shallow_copy[key]     return shallow_copy 

Questions similaires