elbillaf
elbillaf

Reputation: 1994

Scalar Function To Return the Result of A Select

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

Upvotes: 4

Views: 6909

Answers (1)

gbn
gbn

Reputation: 432742

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

...
return (select max(len(password)) from tblSec)
...

Upvotes: 10

Related Questions