473,569 Members | 2,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simple userdefined function question.

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,@currentdat e 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
2 1651
[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,@currentdat e 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****@sommarsk og.se

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

Oct 18 '05 #2
Yes

Oct 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1105
by: Flemming Jensen | last post by:
The idea behind this code is to standardize all my webpages in an application to look the same by inheriting the pages from a userdefined class. But it gives me problems regarding sessionstate... Try creating a new asp.net web application in Visual Studio .NET 2003 on Framework 1.1 using VB language Call the project testform add a new...
4
2002
by: anthony.wolfe | last post by:
Hello all, I'm hoping that someone could help me with this bit of code. I am using reflection to dynamically call a method within an HttpHandler. When a method returns a user defined type that implements a certain interface, I want to call that interfaces method. The problem is that the local varaible holding the user defined type is...
4
118788
by: dba_222 | last post by:
Dear Experts, Ok, I hate to ask such a seemingly dumb question, but I've already spent far too much time on this. More that I would care to admit. In Sql server, how do I simply change a character into a number?????? In Oracle, it is:
6
3163
by: newlearner | last post by:
Hi, i know we can wirte a userdefined callback function.. I had a try for a long time though i feel im near but not able to coin out the exact thing. can any body tell me about a user defined callback function... and a sample on how to write it... looking forward for a reply.. Thanks in advance for your reply...
0
1386
by: Erwin Moller | last post by:
Hi group, I found something strange in PHP5.2.4 (on IIS7/Vista). I am working on an app that has been running just fine under heavy load for over a year at some custumer of mine. (they have PHP5.1 on W2003 Server, ISAPI) I imported the whole project locally on a slightly more modern version of PHP 5.2.4 to make a few adjustments.
0
3046
by: =?Utf-8?B?a3Jpc2huYQ==?= | last post by:
Hi i am getting the following error while using XMLSerializer XmlSerializer ser = new XmlSerializer(typeof(Person)); ERROR: Unable to generate a temporary class (result=1). error CS0266: Cannot implicitly convert type 'XSD.BiodataGender?' to 'XSD.BiodataRace?'. An explicit conversion exists (are you missing a cast?) I am getting the...
1
4437
by: vijaya Lakshmi | last post by:
Hi , We are trying to convert stored procedures from mssql to mysql as a part of db migration, and we are facing the following issue. In mssql , business exceptions can be raised by using RAISERROR function as given below CREATE PROCEDURE dbo.NEXT_SEQ_VAL(@seqName VARCHAR(100),@increment int = 1) AS BEGIN DECLARE @NSN int,
17
5791
by: Chris M. Thomasson | last post by:
I use the following technique in all of my C++ projects; here is the example code with error checking omitted for brevity: _________________________________________________________________ /* Simple Thread Object ______________________________________________________________*/ #include <pthread.h> extern "C" void* thread_entry(void*);
2
1681
by: SnehaAgrawal | last post by:
Does anyone know how to call a UserDefined Function written in SQL 2000 from program(I mean I am writing code in VB.net)..I know how to call it from a stored proc. but don't know how to call from my prog. Like we call stored proc. Thnks
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.