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.
Author |
Topic |
pdude
Starting Member
5 Posts |
Posted - 2010-02-19 : 22:19:13
|
Hi I'm getting this error when I try to run a UDF on 1 of our servers.Msg 102, Level 15, State 1, Line 3Incorrect syntax near '.'.I suspect that it may be due a permissions or config issue at the server level.CREATE FUNCTION dbo.test(@in varchar(max)) RETURNS @t TABLE(val varchar(max))ASBEGIN INSERT INTO @t SELECT substring(@in, 1,3)RETURNENDCREATE TABLE #x(val varchar(max))INSERT INTO #x SELECT 'abcdefg'--this worksSELECT * FROM #x CROSS JOIN dbo.test('abcdefg') xval--val val--abcdefg abcd--but this returns an errorSELECT * FROM #x CROSS JOIN dbo.test(#x.val) xval--Msg 102, Level 15, State 1, Line 3--Incorrect syntax near '.'.Any help would be appreciatedThanks |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-02-19 : 22:34:10
|
you will need to use CROSS APPLY. --but this returns an errorSELECT * FROM #x CROSS JOIN APPLY dbo.test(#x.val) xval--Msg 102, Level 15, State 1, Line 3--Incorrect syntax near '.'. KH[spoiler]Time is always against us[/spoiler] |
 |
|
pdude
Starting Member
5 Posts |
Posted - 2010-02-19 : 22:53:36
|
Hi khtanSorry that was a typo..SELECT * FROM #x CROSS APPLY dbo.test(#x.val) xvalgives me the errorMsg 102, Level 15, State 1, Line 1Incorrect syntax near '.'.pd |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-02-19 : 23:22:00
|
[code]SELECT * FROM #x CROSS APPLY dbo.test(#x.val) xval[/code]This statement is fine. No syntax errorCheck your database compatibility level. It might not be in 90this will show you the current compatibility level of your database[code]select compatibility_level from sys.databases where name = db_name()[/code]to change it, use the ALTER DATABASE commandhttp://msdn.microsoft.com/en-us/library/bb510680.aspxIf this is a live database, you should do this in a testing environment. Refer to above link for further details on difference between comp level 80 and 90 KH[spoiler]Time is always against us[/spoiler] |
 |
|
pdude
Starting Member
5 Posts |
Posted - 2010-02-20 : 01:09:12
|
Hi KhtanYou are a genius...Cheerspd |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-02-20 : 08:58:55
|
quote: Originally posted by pdude Hi KhtanYou are a genius...Cheerspd
Thanks but I'm not. I just can't sleep  KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|