468,242 Members | 1,591 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

Inline table function

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) = '')
* 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
3 1469
1,017 Expert 512MB
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
Tanks man, isnt a bizarre situation anyway?
Sep 15 '08 #3
1,017 Expert 512MB
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.

Similar topics

13 posts views Thread by A | last post: by
4 posts views Thread by Axel Dahmen | last post: by
15 posts views Thread by Dave Townsend | last post: by
7 posts views Thread by Srini | last post: by
33 posts views Thread by Robert Seacord | last post: by
5 posts views Thread by sunil | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.