2

I want a function to find the maximum allowable length of a field; executed as cmd.ExecuteScalar().

This definition fails, why?

CREATE FUNCTION getPWLen
(
)
RETURNS int
AS
BEGIN
   return select max(len((password))) as return_value from tblSec
END
GO
ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122
elbillaf
  • 1,952
  • 10
  • 37
  • 73

1 Answers1

8

No need for a column alias, also wrap the SELECT in brackets

...
return (select max(len(password)) from tblSec)
...
gbn
  • 422,506
  • 82
  • 585
  • 676