473,695 Members | 2,357 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 1659
[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
1113
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 webform called "atest.aspx"
4
2004
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 declared an object. The compiler will accept the invocation of the interface method on that object. I...
4
118814
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
3168
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
1398
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
3052
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 above error when my xsd has multiple nillable elements of userdefined type. If I change the type of...
1
4454
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
5812
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
1686
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
8647
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8585
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8864
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7682
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5842
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3024
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

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.