June 25, 2009 at 1:56 pm
We are converting SS2000 DTS packages to SSIS 2005.
I need help using a User Defined Function within a query on a table.
The function performs correctly.
select * from fn_Split('13.0,13.1,14.0,14.1' ,',')
idx value
0 13.0
1 13.1
2 14.0
3 14.1
This is the table to run the function against, with a few sample record results.
Select versions from versiontable
13.0,13.1,14.0,14.1
13.0,13.1,14.0,14.1
13.0,13.1,14.0,14.1
13.0,13.1,14.0,14.1
11.0,11.1,12.0,12.1,13.0,13.1,14.0
I tried this. Now it no longer recognisee the function. Is the syntax wrong?
select fn_Split(versions, ',') as SingleVersion from versiontable where versions is not null
Server: Msg 195, Level 15, State 10, Line 1
'fn_Split' is not a recognized function name.
Tried this also.
select dbo.fn_Split(versions, ',') as Version from versiontable where versions is not null
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'dbo.fn_Split'.
Any suggestions to get the query to work or even better, a nifty method to accomplish this within my data flow task using one of the Data Flow Transformation. Seems like the pivot might be useful for this?
June 25, 2009 at 3:01 pm
Let's see if it actually made it from one server to another. What do you get when you run the following?
SELECT *
FROM sys.Objects
WHERE Name = 'fn_Split'
If the answer is nothing, then you're either in the wrong database or the CREATE FUNCTION code didn't actually work.
Ummm.... another problem may be the simple matter of privs. It would probably be easiest if you grant EXECUTE to the PUBLIC user on the function.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 25, 2009 at 3:33 pm
Thanks, Jeff.
When I ran your SQL statement, I got this:
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'sys.Objects'.
Privileges, you think?
In my original post, I indicated that the function works when you pass it a literal string.
It only gags when you try to use the function with a table.
Not in the wrong db, but have done that before quite a bit.
Privileges may indeed be the issue.
June 27, 2009 at 8:37 pm
jo stovall (6/25/2009)
Thanks, Jeff.When I ran your SQL statement, I got this:
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'sys.Objects'.
Privileges, you think?
In my original post, I indicated that the function works when you pass it a literal string.
It only gags when you try to use the function with a table.
Not in the wrong db, but have done that before quite a bit.
Privileges may indeed be the issue.
If you're running the query in SQLServer 2000, it would be dbo.SysObjects.
I just went back and took a look at your original post... a split function of this nature usually cannot be used against a table in the normal fashion. You would have to use a Cross-Apply. Of course, you can split the whole table wthout a function to begin with. Please see the following article... (and sorry for the posting delay)....
http://www.sqlservercentral.com/articles/T-SQL/62867/
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply