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
 Transact-SQL (2000)
 Syntax Error Not Understood

Author  Topic 

solart
Posting Yak Master

148 Posts

Posted - 2002-06-10 : 16:45:39
In Query Analyzer when I do this:

CREATE FUNCTION fnStringToken(@InputString varchar(8000), @Delimiter varchar (20), @TokenNum int)
RETURNS VARCHAR(8000)
AS

I get the following message:

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'FUNCTION'.

What is my problem??

Many thanks in advance!!!

Solart

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-06-10 : 18:32:21
Assuming you actually have the whole function defined not just the start and that you're using SQL2000 then this is most likely due to the database compatability level.It needs to be 80 (SQL 2000) in order to CREATE FUNCTION

In QA run

sp_dbcmptlevel 'databasename'

to see what the current setting is. You can also change this via EM by right clicking on the database and going to properties. Click on the Options Tab and you'll see the database compatability dropdown.

HTH
Jasper Smith

Go to Top of Page

solart
Posting Yak Master

148 Posts

Posted - 2002-06-11 : 10:24:52
My error was I was trying to define the function for a SQL 7 DB instead of a SQL 2K DB.

My earnest thanks to Jasper and all.

Gary Andrews.

Go to Top of Page
   

- Advertisement -