0

In my application many I time we use MAX(). How can I write a common function where I can pass table name and column name and get MAX(). I mean single function for any table/field.

Thanks, Tanmay.

gbn
  • 422,506
  • 82
  • 585
  • 676
tanmay
  • 41
  • 1
  • 2

1 Answers1

0

In MSSQL there are no particularly elegant ways to use UDFs with dynamic table/field names, so personally I would just stick to a simple SELECT MAX().

If the IDs are IDENTITY columns you can just use IDENT_CURRENT('the_table')

Community
  • 1
  • 1
Alex K.
  • 171,639
  • 30
  • 264
  • 288