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
 SQL Server Development (2000)
 Function

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-09-16 : 08:38:13
Sabapathy writes "Hi,

I am trying to send a system function as an argument in an user defined function. I am getting an error message while executing the query. For example,

Select * from Table1 T1 where T1.NameID in (select NameId from dbo.MyTableFunction(suser_sname())

Assumed as....
Table1 T1 -- Table
T1.NamdId -- Field of T1

dbo.MyTableFunction is a Table Function
NameId -- Field of MyTableFunction

Can anybody help me to solve this. Also I would like to know that how we can you these kind of table function in views with parameter.

Thanks with regards,
Sabapathy"

rihardh
Constraint Violating Yak Guru

307 Posts

Posted - 2002-09-16 : 09:04:58
Usually I don't like solving other peoples problems writing T-SQL statements, but...:

Assuming that It's the same table wer'e talking about, try this:

SELECT * FROM Table1 T1
WHERE T1.NameID LIKE SUSER_SNAME()

if not try this:

SELECT * FROM Table1 T1
WHERE T1.NameID IN
(SELECT T2.NameId FROM dbo.MyTable T2
WHERE T2.field_user LIKE suser_sname())

or this:

SELECT * FROM Table1 T1 INNER JOIN
dbo.MyTable T2 ON T1.NameID = T2.NameID
WHERE T2.field_user?? LIKE suser_sname()

that's enough for this year.

Go to Top of Page
   

- Advertisement -