Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 C# 和 sql server 2008,我需要从一个表中选择 10 个随机行并将它们插入到另一个表中,我想在 sql server 中使用游标来执行此操作,但我已经阅读了很多关于游标的缺点。现在我想通过 C# 代码做到这一点。有人有更好的建议吗?提前致谢
从 SQL Server 表中选择 n 个随机行的想法
不需要游标:
Insert Into Table1 (col1, col2) Select Top 10 col1, col2 From Table2 Order By NewID()