Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Passing Builtin function as input parameter to UDF

Author  Topic 

kavitaravi
Starting Member

2 Posts

Posted - 2005-07-21 : 02:44:47
Hi,

I am trying to execute the following:
Select * from ManagesUsers(Convert(varchar(30), user_name()))

I get the following error "Incorrect syntax near the keyword 'Convert'"

ManagesUsers is a SQL Server User defined function and accepts
a varchar(30) input parameter.

The following code works fine:
Declare @USerID varchar(30)
Select @USerID = (SELECT convert(char(30),user_name()))
Select * from ManagesUsers(@USerID)

But I need to pass it directly...any idea how to do it?

Thanks.
Kavita.

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-07-21 : 03:04:30
use user instead of user_name()

--edit

actually you need not convert the result from user_name(), i tried this and it's ok

create function dbo.fnTest(@user varchar(20))
returns varchar(20)
as
begin
return @user
end
go

select dbo.fntest(user_name())
go

drop function dbo.fntest

--------------------
keeping it simple...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-21 : 04:14:03
Alternatively you can try

Select * from ManagesUsers((select user_name()))


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -