我正在尝试将 7 种不同类型的啤酒插入我使用 T-SQL 创建的名为 Beers 的表中。我的 VALUES 中不断出现错误,但消息如下:
执行查询时出现以下错误:
Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'VALUES'.
Incorrect syntax near the keyword 'VALUES'.
Incorrect syntax near the keyword 'VALUES'.
Incorrect syntax near the keyword 'VALUES'.
Incorrect syntax near the keyword 'VALUES'.
Incorrect syntax near the keyword 'VALUES'.
Incorrect syntax near the keyword 'VALUES'.
有什么我想念的吗?我无法弄清楚错误是什么。
这是我的 SQL
--将啤酒添加到数据库
SET IDENTITY_INSERT [dbo].[Beers] ON
IF NOT EXISTS (SELECT [BeerId] FROM [dbo].[Beers] WHERE [BeerId] = 1)
INSERT INTO [dbo].[Beers] ([BeerId], [BeerName], [BeerPricePerBottle], [BeerType], [BeerRating], [Enabled], [DateInserted],[DateLastActivity],
VALUES (1, 'Black_Butte', '$9.00', 'porter', NULL, 1, '20071111', '20071111')
IF NOT EXISTS (SELECT [BeerId] FROM [dbo].[Beers] WHERE [BeerId] = 2)
INSERT INTO [dbo].[Beers] ([BeerId], [BeerName], [BeerPricePerBottle], [BeerType], [BeerRating], [Enabled], [DateInserted],[DateLastActivity],
VALUES (2, 'Corona', '$5.00', 'lager', NULL, 1, '20071111', '20071111')
IF NOT EXISTS (SELECT [BeerId] FROM [dbo].[Beers] WHERE [BeerId] = 3)
INSERT INTO [dbo].[Beers] ([BeerId], [BeerName], [BeerPricePerBottle], [BeerType], [BeerRating], [Enabled], [DateInserted],[DateLastActivity],
VALUES (3, 'Duvel', '$12.00', 'pale ale', NULL, 1, '20071111', '20071111')
IF NOT EXISTS (SELECT [BeerId] FROM [dbo].[Beers] WHERE [BeerId] = 4)
INSERT INTO [dbo].[Beers] ([BeerId], [BeerName], [BeerPricePerBottle], [BeerType], [BeerRating], [Enabled], [DateInserted],[DateLastActivity],
VALUES (4, 'Guinness', '$7.00', 'stout', NULL, 1, '20071111', '20071111')
IF NOT EXISTS (SELECT [BeerId] FROM [dbo].[Beers] WHERE [BeerId] = 5)
INSERT INTO [dbo].[Beers] ([BeerId], [BeerName], [BeerPricePerBottle], [BeerType], [BeerRating], [Enabled], [DateInserted],[DateLastActivity],
VALUES (5, 'Heineken', '$6.00', 'lager', NULL, 1, '20071111', '20071111')
IF NOT EXISTS (SELECT [BeerId] FROM [dbo].[Beers] WHERE [BeerId] = 6)
INSERT INTO [dbo].[Beers] ([BeerId], [BeerName], [BeerPricePerBottle], [BeerType], [BeerRating], [Enabled], [DateInserted],[DateLastActivity],
VALUES (6, 'Pilsner_Urquell', '$6.50', 'pilsner', NULL, 1, '20071111', '20071111')
IF NOT EXISTS (SELECT [BeerId] FROM [dbo].[Beers] WHERE [BeerId] = 7)
INSERT INTO [dbo].[Beers] ([BeerId], [BeerName], [BeerPricePerBottle], [BeerType], [BeerRating], [Enabled], [DateInserted],[DateLastActivity],
VALUES (7, 'Stone', '$10.00', 'IPA', NULL, 1, '20071111', '20071111')
SET IDENTITY_INSERT [dbo].[Beers] OFF