Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
uv2944875
Starting Member
5 Posts |
Posted - 2012-11-14 : 10:59:17
|
I have tables Teachers(tid int, teacherName varchar(20)) and Lectures(lid int, tid int, lectureName varchar(20)). This is a simplified version of my tables. A scalar function f(tid int) returns the number of lectures for a teacher. I want to call this function for each teacher in Teachers. Is it possible to implement this without a cursor (in which I place all the teachers and then call the function for each row)? |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-11-14 : 11:00:39
|
You can use APPLY or just selectSelect <columns>,dbo.f(TID) as leacturesFrom TeachersJimEveryday I learn something that somebody else already knew |
|
|
uv2944875
Starting Member
5 Posts |
Posted - 2012-11-14 : 11:12:07
|
Cool, thanks.quote: Originally posted by jimf You can use APPLY or just selectSelect <columns>,dbo.f(TID) as leacturesFrom TeachersJimEveryday I learn something that somebody else already knew
|
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-11-14 : 11:13:14
|
You're Welcome.JimEveryday I learn something that somebody else already knew |
|
|
|
|
|