General information
Title:
Parameterized stored procedure question
Hi,
I need a family of rules that practically beg for a generalized stored procedure with parameters, but I don't know how to do it.
The database contains data for several schools and each school has data for several years. The rules are required to make sure, for example, that a student registered in one school and year is not accidentally placed in a course for a different school or year.
Let's call one procedure (a function really) IsSameSchool with four parameters: Name of table1, Value of PK for table1, Name of table2 and Value of PK for table2. The function already knows the name of the field that contains the school's FK. Let the function figure out which is the PK of each table. I think this requires the equivalent of a macro, and I don't know whether T-SQL even allows that.
A related function might be GetSchool(Name of table, value of PK), but I don't know how to write that one either.
Any suggestions?
TIA,
Alex
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only