0

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 1

3

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()
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.