Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm running this query on SQL Server 2008 R2:

SELECT 
   orr.Rate, orr.ID, orr.UserKey, fn.NetRate 
FROM 
   OngoingRate orr 
CROSS APPLY 
   dbo.GetRateNetView(orr.UserKey) as fn
WHERE 
   orr.UserKey = 5

I get the following error:

Incorrect syntax near '.'.

Please help

share|improve this question
2  
I've updated this answer to include this scenario as well. Still I'm not sure why you had to restart SQL Server - compatibility level changes should take place immediately. Are you 100% certain you were running the query in the context of the database where you changed the compat level? –  Aaron Bertrand May 27 at 16:00
    
Aaron Bertrand: Im Positive, it worked after the restart –  Vuzi May 28 at 7:28
add comment

1 Answer 1

The syntax you have is correct from SQL Server 2005 and up. You are using SQL Server 2008 so it should work just fine unless you have compatibility level for your database set to "SQL Server 2000 (80)".

Make sure you have compatibility level set to at least "SQL Server 2005 (90)".

Right-click on your database - Properties - Options

enter image description here

share|improve this answer
    
I was suspecting the same thing but I updated the compatibility level to SQL Server 2008(100). Let me restart sql server(just in case) –  Vuzi May 27 at 14:26
1  
Hi Mikael, it turns out I had to restart the sql server service for the changes to take effect. Thanks for your contribution –  Vuzi May 27 at 14:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.