1

I have table with the following structure:

FirstName|MiddleName|PatientID

I want in other table to store all distinct FirstNames. I have Created table named TBL and I want to insert into it all distinct FirstName rows. Let's assume first table name uis TBL1. I tried the following:

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

But I've got error:

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

What am I missing here? I am talking about Microsoft Sql Server 2008 R2.

1 Answer 1

2

This should work just fine:

INSERT Into TBL(FirstName) 
SELECT DISTINCT FirstName FROM TBL1

VALUES is for the values in a single row.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.