By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,806 Members | 1,841 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,806 IT Pros & Developers. It's quick & easy.

Inline table function

P: 2
Hello,
I have an inline table function and it takes tow parameters of type VARCHAR.
It functions when I hardcode to string within of call like this:
SELECT * FROM dbo.TestTable(a, b)

Here is definition of inline table function:

FUNCTION GetIPTimeRangeTable (@StartDate VARCHAR(10) = '', @EndDate VARCHAR(10) = '')
RETURNS TABLE
AS
RETURN
(
SELECT
* FROM UserDataSetsAccess
WHERE 1 = 1
AND CreatedAT between @StartDate AND @EndDate
)

If call function like this:
SELECT * FROM GetIPTimeRangeViewTable('2008-7-1', '2008-7-11')
Every ting is OK but if I call function like this
SELECT * FROM GetIPTimeRangeViewTable('2008-7-1', CONVERT(CHAR(10), GETDATE(),121))
I get error:
Incorrect syntax near the keyword 'CONVERT'.
Do you have any explanation for that! Tanks
Sep 15 '08 #1
Share this Question
Share on Google+
3 Replies


iburyak
Expert 100+
P: 1,017
I tried this and it worked

Expand|Select|Wrap|Line Numbers
  1. Declare @A datetime
  2. select @A = CONVERT(CHAR(10), GETDATE(),121)
  3. SELECT * FROM dbo.GetIPTimeRangeTable('2000-08-06', @A)
It is true function is not accepted in a table function as a parameter.

Good Luck.
Sep 15 '08 #2

P: 2
Tanks man, isnt a bizarre situation anyway?
Sep 15 '08 #3

iburyak
Expert 100+
P: 1,017
Tanks man, isnt a bizarre situation anyway?
I am not a man.... :) But anyway I saw such behavior in other places so we have to work with what we have.
Sep 15 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.