Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7525587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:35:33+00:00 2026-05-30T03:35:33+00:00

I have a SQL Server 2008 R2 Instance with several databases on it. I’m

  • 0

I have a SQL Server 2008 R2 Instance with several databases on it.

I’m trying to run a Table-Valued Function on one of the databases (let’s call it DB1) that will take a date as an input and return a table of relevant information.

I run my query as such:

SELECT * FROM dbo.getAllStatusesForGridProjectsByMaximumDate(CURRENT_TIMESTAMP) 

to get the most up-to date information. Instead of the result table, however, SQL just kicks the error:

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'CURRENT_TIMESTAMP'.

What’s strange though is that if I hop onto another database (DB2) and run the function while specifically referencing the server, it runs:

USE DB2
GO

SELECT * FROM DB1.dbo.getAllStatusesForGridProjectsByMaximumDate(CURRENT_TIMESTAMP) 

That returns results. If I try and run the query off of DB1, though, it kicks back that same Incorrect syntax error:

USE DB1
GO

SELECT * FROM DB1.dbo.getAllStatusesForGridProjectsByMaximumDate(CURRENT_TIMESTAMP) 

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'CURRENT_TIMESTAMP'.

I’ve looked through the databases to see if there’s some sort of setting or property that I missed that would allow me to pass CURRENT_TIMESTAMP to my Table-Valued function and haven’t found anything. I’ve tried an explicit CAST/CONVERT of CURRENT_TIMESTAMP, and it doesn’t like any kind of function in there.

What witchcraft has been performed upon my DB2 that would allow it to run dbo.Function(Current_Timestamp) that hasn’t been performed on DB1? I’m going to keep checking on my own, but any help you wonderful people could send would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:35:34+00:00Added an answer on May 30, 2026 at 3:35 am

    Check the compatibility level of the database (it wasn’t 100% clear if the problem was happening in DB1 or when calling the function in DB1).

    I bet the compatibility level is 80 in whatever database is exhibiting the problem; SQL Server 2000 didn’t allow functions to be passed directly to UDFs that way (and we have the same problem calling some of the dynamic management functions if the compat level is 80 – see this blog post and the comments). This database must have been restored or attached after being backed up or detached from 2000. Or after being upgraded from 2000. You can check the current compatibility this way:

    SELECT name, compatibility_level FROM sys.databases WHERE name = 'DB1';
    

    If you find it is < 100, you can say:

    ALTER DATABASE DB1 SET COMPATIBILITY_LEVEL = 100;
    

    But you should only do so if you know that the lower comptibility is not needed for some other reason – and you should validate on a test system that the database works as expected under the new compat level. If you have problems, you can always change it back, but it’s better to be prepared.

    If you don’t want to mess with the compatibility level, you can change your logic slightly.

    DECLARE @now DATETIME = CURRENT_TIMESTAMP;
    SELECT * FROM dbo.getAllStatusesForGridProjectsByMaximumDate(@now);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server 2008 instance with several databases and I'm currently writing
I have an extensive maintenence plan on one sql server 2008 instance that I
I have this table in a SQL Server 2008 R2 instance which I have
I have an SQL server 2008 database instance on one machine. Now I want
I have two named instances of SQL Server 2008 and am trying to set
I have SQL Server 2008 with a table called ProductCategories designed like this: Id
I have two SQL Server 2008 databases called Anna and Bob . Bob has
I have within my Sql Server 2008 database a trigger which will run on
i have an instance of SQL server 2008 and an instance of SQL server
I have a database called MyDB in a Microsoft SQL Server 2008 Express instance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.