By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,231 Members | 1,507 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,231 IT Pros & Developers. It's quick & easy.

simple userdefined function question.

P: n/a
Hi All!

This is the first time i am tryin to write a sql server 2000 function.
I need to clean up some of my stored procedures..

Can any one please give me skeleton for a userdefined function or
correct my function. I get the following error.

Select statements included within a function cannot return data to a
client.

This returns a bit and it does a query to the database to decide the
value of the bit

CREATE FUNCTION GoodAd
(@adid int,@currentdate datetime)
RETURNS bit
AS
BEGIN
declare @Return bit
select @return = 1

if exists (select null from adqas where adid=@adid)
select @return 0
return @return
end

Oct 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
[posted and mailed, please reply in news]

parez (ps*****@gmail.com) writes:
This is the first time i am tryin to write a sql server 2000 function.
I need to clean up some of my stored procedures..

Can any one please give me skeleton for a userdefined function or
correct my function. I get the following error.

Select statements included within a function cannot return data to a
client.
Looks like a simple syntax error to me:
CREATE FUNCTION GoodAd
(@adid int,@currentdate datetime)
RETURNS bit
AS
BEGIN
declare @Return bit
select @return = 1

if exists (select null from adqas where adid=@adid)
select @return 0

I guess you mean:

select @return = 0


--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Oct 18 '05 #2

P: n/a
Yes

Oct 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.