Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with User Defined Function

Status
Not open for further replies.

jgd1234567

Programmer
May 2, 2007
68
GB
Hi i have a user defined function (called IsValid) which has one parameter and returns a bit. I need to create a sql statement which returns any rows in a table where the function returns 1 based on the inputted value, ie

SELECT * FROM Groups WHERE dbo.IsValid(GroupID) = 1

But the above does not work. I'm pretty new to user defined functions and do not understand how and where i can use them. I could create the above as a stored procedure if i have to but i still do not understand how this could be achieved.

Appreciate if someone could help.
 
Could you post function code?
The statement above is valid, so maybe there is something about your function :)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
Microsoft MVP VFP
 
What do you mean, does not work? If its' not returning any results, perhaps your function is written in such a way that no GroupID's are actually valid?

Hope this helps,

Alex

[small]----signature below----[/small]
Now you can go where the people are one!
Now you can go where they get things done!
 
Has your function been set to RETURN the bit value?
The BEGIN...END must at some point issue a RETURN but I would guess you have treated it like a stored procedure and not set this correctly.

Post the code so we can see.


Dazed and confused
 
Hi cheers people, you guessed right. It was the function that was causing the problem after all.

Appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top