2012-09-02 72 views
1

使用子查詢我有表結構如下:錯誤而在插入操作

FirstName|MiddleName|PatientID 

我想在其他表來存儲所有不同FirstNames。我創建了一個名爲TBL的表,並且我想將其插入到所有不同的FirstName行中。我們假設第一個表名uis TBL1。我試過如下:

INSERT Into TBL(FirstName) VALUES (SELECT DISTINCT FirstName FROM TBL1) 

但我有錯誤:

Subquery returned more than 1 value. This is not permitted when the subquery follows =, ! =, <, <= , >, >= or when the subquery is used as an expression.

缺少什麼我在這裏?我正在談論微軟Sql Server 2008 R2。

回答

2

這應該只是罰款:

INSERT Into TBL(FirstName) 
SELECT DISTINCT FirstName FROM TBL1 

VALUES是在行的值。

+0

是的,就是這樣。+ 1 – seeker