I am using C# and sql server 2008,I need to select 10 random rows from one table and insert them to another table and I wanted to do this with cursor in sql server,but I have read a lot about disadvantages of cursor.Now I want to do this via C# code.Does anybody have a better suggestion?? thanks in advance
1 Answer
Idea from Select n random rows from SQL Server table
No cursors required:
Insert Into Table1
(col1, col2)
Select Top 10
col1, col2
From
Table2
Order By
NewID()