Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored procedure with openquery

Status
Not open for further replies.

psychodad71

IS-IT--Management
May 22, 2003
10
DE
Hi,

do anyone find the fault ?

------------------------------

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO



ALTER PROCEDURE [Fallauskunft]
(@nr int)

AS
begin
declare @alles varchar(8000)
select @alles ='
select * from openquery (connection, ''select *
from connection..view_dale2.VP where original_vers_id ='''+ @nr+''')'
exec (@alles)
END
GO

------------------------------------

Uli
 
ALTER PROCEDURE [Fallauskunft](@nr int)
AS
declare @alles varchar(8000)
select @alles ='select * from openquery (connection,'+
'"select * from connection..view_dale2.VP where original_vers_id ='+"'"+convert(varchar,@nr)+"'"+'")'
exec(@alles)
 
Sorry it does not work. There must by something wrong with the select statement. Any ideas ?

ULi
 
May be two dots in 'connection..view_dale2.VP'

Zhavic

---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Try that
select @alles ='
select * from openquery (connection, ''select *
from connection..view_dale2.VP where
(original_vers_id = '''''+ @nr+ ''''')'')'
 
I did not see so your @nr must be a varchar
convert first
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO



ALTER PROCEDURE [Fallauskunft]
(@nr int)

AS
begin
declare @alles varchar(8000),@nr1 varchar(10)
set @nr1 = convert(varchar,@nr)
select @alles ='
select @alles ='
select * from openquery (connection, ''select *
from connection..view_dale2.VP where
(original_vers_id = '''''+ @nr1+ ''''')'')'
exec (@alles)
END
GO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top