hi
i have 4000 records, and i need to pick randomize 500 records.
i need that 500 records will insert to GoodTable
and the rest 3500 records will insert to BadTable
how to do it using sql-server 2008 query ?
thank's in advance
hi
i have 4000 records, and i need to pick randomize 500 records.
i need that 500 records will insert to GoodTable
and the rest 3500 records will insert to BadTable
how to do it using sql-server 2008 query ?
thank's in advance
This should work in Transact-SQL:
insert into GoodTable
select top 500 * from OtherTable order by newid()
EDIT: this might be better, it'll create the GoodTable for you automatically (instead of needing to create it manually beforehand with appropriate columns):
select top 500 *
into GoodTable
from OtherTable
order by newid()