SQLTeam.com | Weblogs | Forums

CURSOR in stored procedure


I want to create a cursor in a stored procedure. What this procedure does is that:
-Adds the same column (PARENT_COLUMN as INT) to two tables (STUDENT, GRADE_EVENT), not all tables. The database I use is STUDENTDB.
Any help, please.
Thank you.


This needs neither a cursor nor a stored procedure:

alter table STUDENT add PARENT_COLUMN int;
alter table GRADE_EVENT add PARENT_COLUMN int;

Even if you wrote a procedure, with or without a cursor, it would have to execute those 2 statements and can only run once, since column names must be unique within a table.


Sounds like homework ... if your Prof is asking you to write a Cursor then ... my only advice is that good SQL coding will avoid cursors and use Set Based methods instead, so I suggest challenging what the benefit of a Cursor is in the general area being taught