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.