November 13, 2002 at 9:55 am
Calling a function from linked SQL Server received error message.
SELECT * FROM TSTCMSDB1...usysprocess(51)
Server: Msg 170, Level 15, State 31, Line 1
Line 2: Incorrect syntax near '('.
Here are function defined in the linked server.
CREATE FUNCTION usysprocess (@spid int)
RETURNS TABLE
AS
RETURN (SELECT * from sysprocesses s
WHERE s.spid = @spid
Thanks.
November 13, 2002 at 9:59 am
You normally have to specify the user name (e.g. dbo) when calling a UDF.
Have you tried......
SELECT * FROM TSTCMDDB1..dbo.usysprocess(51)
....only a guess!
November 13, 2002 at 10:23 am
You need to include all parts of the 4 part name in the call i.e. server.database.user.object
Simon Sabin
Co-author of SQL Server 2000 XML Distilled
http://www.amazon.co.uk/exec/obidos/ASIN/1904347088
Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons
November 13, 2002 at 1:25 pm
I agree with Simon Sabin.
November 14, 2002 at 12:27 pm
Try SELECT * FROM TSTCMDDB1.master.dbo.usysprocess(51) but it still doesn't work. Same error message.
Edited by - Allen_Cui on 11/14/2002 12:28:14 PM
November 14, 2002 at 3:34 pm
I remember somewhere someone stateing they can only use it with OPENQUERY.
I think there is a limitation in the ability to return UDF with table returns that prevents them. Or you have to turn something else on.
However, try this to see if works.
SELECT * FROM TSTCMDDB1.master.dbo.[usysprocess(51)]
I don't know what will happen since I haven't tested.
Now the other question I have is why didn't you just select from the sysprocesses table yourself? Or make an Procedure instead?
November 14, 2002 at 4:05 pm
Antares is right...you must call it like this:
select * from OPENQUERY(TSTCMDDB1,'select * from master.dbo.usysprocess(51)')
-Dan
-Dan
November 14, 2002 at 4:52 pm
The openquery method is what we use. Works fine.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply