我寫它有多個SELECT語句在INSERT語句中的查詢錯誤在插入語句多個SELECT語句
INSERT INTO dbo.Products
(ProductName,
SupplierID,
CategoryID,
UnitsInStock,
UnitsOnOrder,
ReorderLevel,
Discontinued)
VALUES
('Twinkies' ,
(SELECT SupplierID FROM dbo.Suppliers WHERE CompanyName = 'Lyngbysild'),
(SELECT CategoryID FROM dbo.Categories WHERE CategoryName = 'Confections'),
0,
0,
10,
0)
其實它給錯誤
Msg 1046, Level 15, State 1, Line 4
Subqueries are not allowed in this context. Only scalar expressions are allowed.
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near ','.
如果這兩個select語句只返回一個值。
+1偉大的...謝謝 – Azhar 2011-02-02 14:53:38