Hello All,
I want to know whether it is possible to initialize an input variable in a user-defined function. If so, then how it should be used in a select query?
create function dbo.udfgetloc (@locid int, @typ int = 0)
returns varchar(10) as
begin
declare @STR varchar(10)
if @typ = 0
select @STR = query
else
select @STR = query
return @STR
end
Now, i want to use the above function in a select query.
select name, dbo.udfgetloc(1) Location from <tablename> -- is it correct.
i am getting error saying that insufficient number of arguments were supplied to the function.
My question -- is it wise to initialize an input variable in a user-defined function?
Thanks in advance.