Re: Help with UDF using OPENROWSET to EXECUTE sproc
From: Adam Machanic (amachanic_at_hotmail._removetoemail_.com)
Date: 12/30/04
- Next message: Wayne Snyder: "Re: Converting a SQL Database to MSDE"
- Previous message: MisterB: "Converting a SQL Database to MSDE"
- In reply to: JJA: "Help with UDF using OPENROWSET to EXECUTE sproc"
- Next in thread: JJA: "Re: Help with UDF using OPENROWSET to EXECUTE sproc"
- Reply: JJA: "Re: Help with UDF using OPENROWSET to EXECUTE sproc"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 30 Dec 2004 13:29:12 -0500
OPENROWSET is opening the connection to MDWDATA and executing the following
(literally):
'EXECUTE dbo.AccountFetchCounties NULL, @SourceTable, @UserName '
It has no idea what @SourceTable and @UserName are. Unfortunately, there's
no way I know of to pass values into OPENROWSET within a UDF.
Can you describe what you're trying to do? Maybe there's a better way than
using a UDF.
-- Adam Machanic SQL Server MVP http://www.sqljunkies.com/weblog/amachanic -- "JJA" <johna@cbmiweb.com> wrote in message news:1104430908.817837.179350@z14g2000cwz.googlegroups.com... > Here is the UDF I am trying to create: > > ALTER FUNCTION dbo.TieredAccessCounties > ( > @State CHAR(2) > , @SourceTable CHAR(1) > , @UserName VARCHAR(30) > ) > RETURNS TABLE > AS > RETURN > SELECT A.* FROM > OPENROWSET('SQLOLEDB','MDWDATA';'sa';'passwordX', > 'EXECUTE dbo.AccountFetchCounties NULL, @SourceTable, @UserName ') > AS A > > I cannot get this to work. I am getting these messages: > > Server: Msg 8180, Level 16, State 1, Procedure TieredAccessCounties, > Line 10 > Statement(s) could not be prepared. > Server: Msg 137, Level 15, State 1, Procedure TieredAccessCounties, > Line 10 > Must declare the variable '@SourceTable'. > [OLE/DB provider returned message: Deferred prepare could not be > completed.] >
- Next message: Wayne Snyder: "Re: Converting a SQL Database to MSDE"
- Previous message: MisterB: "Converting a SQL Database to MSDE"
- In reply to: JJA: "Help with UDF using OPENROWSET to EXECUTE sproc"
- Next in thread: JJA: "Re: Help with UDF using OPENROWSET to EXECUTE sproc"
- Reply: JJA: "Re: Help with UDF using OPENROWSET to EXECUTE sproc"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
Loading