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)
 what's wrong with this syntax ?

Author  Topic 

lalbatros
Yak Posting Veteran

69 Posts

Posted - 2008-02-01 : 01:25:54
I don't see why I get a syntax problem in this code:

quote:
ALTER FUNCTION dbo.limitExceeded
(
@var FLOAT,
@limit FLOAT
)

RETURNS INT

AS
BEGIN

DECLARE @ret int;
IF @var > @limit
SELECT @ret = 1
ELSE
SELECT @ret = 0

RETURN @ret
END


I am using access 2003 as front-end and I get this error message:

quote:
ADO error: Incorrect sysntax near the keyword 'ALTER'.
'ALTER FUNCTION' must be the first statement in a query batch.
Must declare the variable '@var'.
Incorrect syntax near the keyword 'ELSE'.
Line 6: Incorrect synstax near ')'.


Thanks for your patient help ...

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-01 : 02:18:30
T-SQL functions are not availabled in Access 2003. VBA functions are.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

lalbatros
Yak Posting Veteran

69 Posts

Posted - 2008-02-01 : 02:48:41
Peso,

I am using an adp project in Access, connected to an SqlServer database.
I have run many such functions in Access, that I copied from the web.
See my question from yesterday for example: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=96521 .

The difference for today is that I am trying to write my first function by myself ... ;>) ...
I really would prefer to do that in VB or java or C#, I dislike this SQL stuff !
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-01 : 03:15:20
Ok... Then we move on to the next line in the error message.
Put a single GO on the line above "ALTER FUNCTION..." and under END

GO
ALTER FUNCTION...
..
..
GO



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

lalbatros
Yak Posting Veteran

69 Posts

Posted - 2008-02-01 : 07:31:41
Peso,
What is the meaning of this 'GO' ?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-02-01 : 07:41:59
Please refer to the Books OnLine http://msdn2.microsoft.com/en-us/library/ms188037.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

lalbatros
Yak Posting Veteran

69 Posts

Posted - 2008-02-01 : 15:28:36
Looks like chinese for me ;>) !
What is a batch, to start with, and why is that important or even necessary?
After all, I just wanted to define a simple elementary function, and I know have to learn about batches ... ?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-02-01 : 21:29:42
quote:
Looks like chinese for me ;>) !

it is in perfect English. If it is in Chinese, i can translate for you


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

lalbatros
Yak Posting Veteran

69 Posts

Posted - 2008-02-02 : 12:12:49
khtan,

That's probably why you are more confortable than me with tsql ! ;>)
Go to Top of Page
   

- Advertisement -