While this thread was useful for you from the standpoint of understanding how to call udfs, you might want to look at the T-SQL GetUTCDate() function before you reinvent the...
As an aside, I actually looked at what your cursor is doing. Have you considered using the sadly undocumented sp_MSforeachtable stored procedure to see if it fits your needs?
You can't use a variable directly in place of a table name in that SELECT statement. You can accomplish it by turning the select statement into a string, and performing...
I have a question which should help us come up with an answer. In your example above, you wanted 3 and 6 returned, and while it's pretty clear how to...