Ya know...I thought it was a neat academic thing to give a shot at...
but it's a bad idea...why would you need to do this...
and if you want to continue...this was my (failed) attempt
CREATE TABLE myTable99(Col1 varchar(800))
CREATE FUNCTION tn_getmax (@tablefield sysname, @tablename sysname)
DECLARE @x varchar(8000), @y varchar(8000)
DELETE FROM myTable99
SELECT @x = 'INSERT INTO myTable99(Col1) SELECT MAX('+@tablefield+') FROM '+@tablename
SELECT @y = Col1 FROM myTable99