Showing posts with label linkedserver. Show all posts
Showing posts with label linkedserver. Show all posts

Sunday, March 11, 2012

calling a remote SP call that returns a cursor

Hi,
a SP in my database is calling a SP in external database using a linked
server.
ie ni my SP: exec YourLink.YourDB.dbo.GetResultsSP @.CursorReturn out
the SP in the external database must return me a result set OR cursor. I
have having issues reading the result set from my SP so have tried
implementing logic as a cursor. I get error to do with RPC and cursors not
allowed.
Is there any way I can get this cursor back to my SP if it is returned as
just a default result set from the external SP? or if not then as a defined
cursor?
Any help would be apprecated,
SteveI read this post after reading your later on.
You could try returning table datatype from a user defined function from
your remote procedure call.
In your calling procedure, you could get resultset from the table datatype
returned from user defined function.
Please let me know if I misunderstood your question or you need more help on
this.
--
http://zulfiqar.typepad.com
BSEE, MCP
"Steve" wrote:

> Hi,
> a SP in my database is calling a SP in external database using a linked
> server.
> ie ni my SP: exec YourLink.YourDB.dbo.GetResultsSP @.CursorReturn out
> the SP in the external database must return me a result set OR cursor. I
> have having issues reading the result set from my SP so have tried
> implementing logic as a cursor. I get error to do with RPC and cursors not
> allowed.
> Is there any way I can get this cursor back to my SP if it is returned as
> just a default result set from the external SP? or if not then as a define
d
> cursor?
> Any help would be apprecated,
> Steve|||Hi,
it is a 3rd party vendor db and they have "exposed" a public SP that I can
call to get all time and attendance activity for a period of time that I pas
s
as parameters.
The issue is that the vendor SP returns the rows as a result set of the SP
and I am finding it difficult to load these into my SP for processing.
I could potentially contact the vendor and ask them to make some changes but
I need to be clear on what I need them to do.
thanks,
Steve
"ZULFIQAR SYED" wrote:
> I read this post after reading your later on.
> You could try returning table datatype from a user defined function from
> your remote procedure call.
> In your calling procedure, you could get resultset from the table datatype
> returned from user defined function.
> Please let me know if I misunderstood your question or you need more help
on
> this.
> --
> http://zulfiqar.typepad.com
> BSEE, MCP
>
> "Steve" wrote:
>|||Here I got some of the code from BOL (books online) to give you an example
on how to populate a table from a SP resultset.
HTH..
use pubs
go
drop table author_sales
go
CREATE TABLE author_sales
( data_source varchar(20),
au_id varchar(11),
au_lname varchar(40),
sales_dollars smallmoney
)
GO
-- ========================================
=====
-- Create procedure basic template
-- ========================================
=====
-- creating the store procedure
IF EXISTS (SELECT name
FROM sysobjects
WHERE name = N'mytestprocA'
AND type = 'P')
DROP PROCEDURE dbo.mytestprocA
GO
CREATE PROCEDURE dbo.mytestprocA
AS
INSERT author_sales EXECUTE get_author_sales
select * from author_sales
GO
-- ========================================
=====
-- example to execute the store procedure
-- ========================================
=====
EXECUTE dbo.mytestprocA
GO
http://zulfiqar.typepad.com
BSEE, MCP
"Steve" wrote:
> Hi,
> it is a 3rd party vendor db and they have "exposed" a public SP that I can
> call to get all time and attendance activity for a period of time that I p
ass
> as parameters.
> The issue is that the vendor SP returns the rows as a result set of the SP
> and I am finding it difficult to load these into my SP for processing.
> I could potentially contact the vendor and ask them to make some changes b
ut
> I need to be clear on what I need them to do.
> thanks,
> Steve
> "ZULFIQAR SYED" wrote:
>

Wednesday, March 7, 2012

Call remote proc in TSQL

I have two SQL Servers, both in the same domain. My domain account is
defined as a system administrator on both. On one server I set up a linked
server definition to the other and told it to use "logins current security
context". On the second I created a procedure spHelloWorld in master that
creates a table and stuffs a message into it. I tested the proc on that
server and it works fine. I logged into the first server using Query
Analyser using my domain account. I then execute this :
exec RMTSRVRNAME.master.dbo.spHelloWorld.
I get back this error:
Server: Msg 18452, Level 14, State 1, Line 1
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.
I f I change the linked server propertyies to always use the sa/password of
the linked server it works fine. What am I missing here? Can't I use
windows authentication with linked servers?
Barry
Check out "Security Account Delegation" in the BOL.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com
<barryfz@.home.com> wrote in message
news:uk2AGGPvEHA.2536@.TK2MSFTNGP11.phx.gbl...
I have two SQL Servers, both in the same domain. My domain account is
defined as a system administrator on both. On one server I set up a linked
server definition to the other and told it to use "logins current security
context". On the second I created a procedure spHelloWorld in master that
creates a table and stuffs a message into it. I tested the proc on that
server and it works fine. I logged into the first server using Query
Analyser using my domain account. I then execute this :
exec RMTSRVRNAME.master.dbo.spHelloWorld.
I get back this error:
Server: Msg 18452, Level 14, State 1, Line 1
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.
I f I change the linked server propertyies to always use the sa/password of
the linked server it works fine. What am I missing here? Can't I use
windows authentication with linked servers?
Barry
|||barry
EXEC sp_serveroption SERVER, 'data access' , 'true'
go
use pubs
go
create procedure proc_BARRY
select * from dbo.authors
go
select *
from OPENQUERY(OPUSPENGUIN,'exec pubs.dbo.proc_BARRY')
go
-- clean-up
drop procedure proc_BARRY
go
<barryfz@.home.com> wrote in message
news:uk2AGGPvEHA.2536@.TK2MSFTNGP11.phx.gbl...
> I have two SQL Servers, both in the same domain. My domain account is
> defined as a system administrator on both. On one server I set up a linked
> server definition to the other and told it to use "logins current security
> context". On the second I created a procedure spHelloWorld in master that
> creates a table and stuffs a message into it. I tested the proc on that
> server and it works fine. I logged into the first server using Query
> Analyser using my domain account. I then execute this :
> exec RMTSRVRNAME.master.dbo.spHelloWorld.
> I get back this error:
> Server: Msg 18452, Level 14, State 1, Line 1
> Login failed for user '(null)'. Reason: Not associated with a trusted SQL
> Server connection.
> I f I change the linked server propertyies to always use the sa/password
of
> the linked server it works fine. What am I missing here? Can't I use
> windows authentication with linked servers?
>
> Barry
>
|||Hi Barry ,
I wanted to post a quick note to see if you would like additional
assistance or information regarding this particular issue. Have you tried
Uri Dimant's statement? We appreciate your patience and look forward to
hearing from you!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!
|||I have check out the recommendations suggested and found them useful but I
am still having a problem. What I have done now is made my remote server a
linked Server using Enterprise Manager and for now I have set the security
to map to the sa for all requests. The remote server is names Mikey. When I
run this:
select * from mikey.master.dbo.CPIRestoreDB
I get back the rows from the table
But when I run this:
exec mikey.master.dbo.spHelloWorld
I get:: Could not execute procedure on remote server 'mikey' because SQL
Server is not configured for remote access.
Why can't I run a sp?
Barry
|||barryfz@.home.com wrote:
> I have check out the recommendations suggested and found them useful
> but I am still having a problem. What I have done now is made my
> remote server a linked Server using Enterprise Manager and for now I
> have set the security to map to the sa for all requests. The remote
> server is names Mikey. When I run this:
> select * from mikey.master.dbo.CPIRestoreDB
> I get back the rows from the table
> But when I run this:
> exec mikey.master.dbo.spHelloWorld
> I get:: Could not execute procedure on remote server 'mikey'
> because SQL Server is not configured for remote access.
> Why can't I run a sp?
> Barry
AFAIK, in the linked server properties, check the box "RPC in", right?
|||Hi Barry,
Have you tried Zarko Jovanovic's suggestion? I wanted to post a quick note
to see if you would like additional assistance or information regarding
this particular issue. We appreciate your patience and look forward to
hearing from you!
Thank you for your patience and corporation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!

Call remote proc in TSQL

I have two SQL Servers, both in the same domain. My domain account is
defined as a system administrator on both. On one server I set up a linked
server definition to the other and told it to use "logins current security
context". On the second I created a procedure spHelloWorld in master that
creates a table and stuffs a message into it. I tested the proc on that
server and it works fine. I logged into the first server using Query
Analyser using my domain account. I then execute this :
exec RMTSRVRNAME.master.dbo.spHelloWorld.
I get back this error:
Server: Msg 18452, Level 14, State 1, Line 1
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.
I f I change the linked server propertyies to always use the sa/password of
the linked server it works fine. What am I missing here? Can't I use
windows authentication with linked servers?
BarryCheck out "Security Account Delegation" in the BOL.
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com
<barryfz@.home.com> wrote in message
news:uk2AGGPvEHA.2536@.TK2MSFTNGP11.phx.gbl...
I have two SQL Servers, both in the same domain. My domain account is
defined as a system administrator on both. On one server I set up a linked
server definition to the other and told it to use "logins current security
context". On the second I created a procedure spHelloWorld in master that
creates a table and stuffs a message into it. I tested the proc on that
server and it works fine. I logged into the first server using Query
Analyser using my domain account. I then execute this :
exec RMTSRVRNAME.master.dbo.spHelloWorld.
I get back this error:
Server: Msg 18452, Level 14, State 1, Line 1
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.
I f I change the linked server propertyies to always use the sa/password of
the linked server it works fine. What am I missing here? Can't I use
windows authentication with linked servers?
Barry|||barry
EXEC sp_serveroption SERVER, 'data access' , 'true'
go
use pubs
go
create procedure proc_BARRY
select * from dbo.authors
go
select *
from OPENQUERY(OPUSPENGUIN,'exec pubs.dbo.proc_BARRY')
go
-- clean-up
drop procedure proc_BARRY
go
<barryfz@.home.com> wrote in message
news:uk2AGGPvEHA.2536@.TK2MSFTNGP11.phx.gbl...
> I have two SQL Servers, both in the same domain. My domain account is
> defined as a system administrator on both. On one server I set up a linked
> server definition to the other and told it to use "logins current security
> context". On the second I created a procedure spHelloWorld in master that
> creates a table and stuffs a message into it. I tested the proc on that
> server and it works fine. I logged into the first server using Query
> Analyser using my domain account. I then execute this :
> exec RMTSRVRNAME.master.dbo.spHelloWorld.
> I get back this error:
> Server: Msg 18452, Level 14, State 1, Line 1
> Login failed for user '(null)'. Reason: Not associated with a trusted SQL
> Server connection.
> I f I change the linked server propertyies to always use the sa/password
of
> the linked server it works fine. What am I missing here? Can't I use
> windows authentication with linked servers?
>
> Barry
>|||Hi Barry ,
I wanted to post a quick note to see if you would like additional
assistance or information regarding this particular issue. Have you tried
Uri Dimant's statement? We appreciate your patience and look forward to
hearing from you!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!|||I have check out the recommendations suggested and found them useful but I
am still having a problem. What I have done now is made my remote server a
linked Server using Enterprise Manager and for now I have set the security
to map to the sa for all requests. The remote server is names Mikey. When I
run this:
select * from mikey.master.dbo.CPIRestoreDB
I get back the rows from the table
But when I run this:
exec mikey.master.dbo.spHelloWorld
I get:: Could not execute procedure on remote server 'mikey' because SQL
Server is not configured for remote access.
Why can't I run a sp'
Barry|||barryfz@.home.com wrote:
> I have check out the recommendations suggested and found them useful
> but I am still having a problem. What I have done now is made my
> remote server a linked Server using Enterprise Manager and for now I
> have set the security to map to the sa for all requests. The remote
> server is names Mikey. When I run this:
> select * from mikey.master.dbo.CPIRestoreDB
> I get back the rows from the table
> But when I run this:
> exec mikey.master.dbo.spHelloWorld
> I get:: Could not execute procedure on remote server 'mikey'
> because SQL Server is not configured for remote access.
> Why can't I run a sp'
> Barry
AFAIK, in the linked server properties, check the box "RPC in", right?|||Hi Barry,
Have you tried Zarko Jovanovic's suggestion? I wanted to post a quick note
to see if you would like additional assistance or information regarding
this particular issue. We appreciate your patience and look forward to
hearing from you!
Thank you for your patience and corporation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!