OBL
OBL

Reputation: 1357

SQL insert with one row duplicate rows

From this table:

DECLARE @tmp TABLE (id int, ahccs int, info varchar(25), endDate date)

5   123 et  2012-09-15
2   321 et  2012-04-27
2   321 et  2012-04-27
2   321 et  2012-04-27
3   134 et  2012-04-27

How could I insert only these values to another table

5   123 et  2012-09-15
2   321 et  2012-04-27
3   134 et  2012-04-27

Thanks!

Upvotes: 1

Views: 98

Answers (1)

user1200540
user1200540

Reputation:

Using the Distinct Keyword:

Create table TableName AS (Select Distinct [id] as id, [ahccs] as ahccs, [info] as info, [endDate] as endDate From Table_Name)

Upvotes: 3

Related Questions