Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 inserting unique data

Author  Topic 

sudha12345
Starting Member

47 Posts

Posted - 2009-04-28 : 04:21:18
i has a table wih column a which has rows
6
6
5
8
14

i want to insert unique data into another table wih column b
like
6
5
8
14 without using Distinct key word

Sudhakar

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-04-28 : 04:23:48
insert into tableb (id)
select id from (
select row_number()over(partition by id order by id) as rid, id
from tablea
) s where rid =1
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-04-28 : 04:31:02
quote:
without using Distinct key word


Hmmm . . . Smell like homework. What wrong with using DISTINCT ? Can you use GROUP BY ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -