Help me with this SQL: 'DO THIS for ALL ROWS in TABLE'
sql, sql-server, sql-server-2005, t-sql
Solution
Something like:
insert into CourseAssignment (CourseId, StudentId)
select 1 -- whatever the course number is
, StudendId
from Student
Problem
[using SQL Server 2005] I have a table full of users, I want to assign every single user in the table (16,000+) to a course by creating a new entry in the assignment table as well as a new entry in the course tracking table so their data can be tracked. The problem is I do no know how to do a loop in SQL because I don't think you can but there has got to be a way to do this... FOR EACH user in TABLE write a row to each of the two tables with userID from user TABLE... how would I do this? please help!