Re: Question on OpenQuery
From: Chris (anonymous_at_discussions.microsoft.com)
Date: 03/24/04
- Next message: Kalen Delaney: "Re: How to change owner of user datatype?"
- Previous message: Eric Hirst: "Re: Slow performance after restarting"
- In reply to: Adam Machanic: "Re: Question on OpenQuery"
- Next in thread: Adam Machanic: "Re: Question on OpenQuery"
- Reply: Adam Machanic: "Re: Question on OpenQuery"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 24 Mar 2004 10:31:05 -0800
Hi Adam,
I follow your example and come up with this:
create function GetQuantityDeliveredByStore(
@storeID varchar(10),
@productNumber varchar(10),
@coverDate varchar(10)
)
returns INT AS
BEGIN
declare @returnval INT
select @returnval = sum(quantity + overage - notdeliv - short - damaged) from OPENQUERY(PROGLINK, 'select quantity,overage,notdeliv,short,damaged
from history where id =' + '"' + (@storeID) + '"' 'and number =' + (@productNumber) + 'and cover-date =' + (@coverDate) + '''')
return @returnval
end
The query is runs excellent if I assign values instrad of the variables(@storeID, @productNumber, @coverDate) like this
declare @test int
select @test = sum(quantity + overage - notdeliv - short - damaged) from OPENQUERY(PROGLINK, 'select quantity,overage,notdeliv,short,damaged
from history where id = "s0912070" and number = 92219 and cover-date = 08/25/2003')
select @test
but when I try to create the function above I get an error
Server: Msg 170, Level 15, State 1, Procedure GetQuantityDeliveredByStore, Line 19
Line 19: Incorrect syntax near '+'
Can I really pass the variables in the openquery by using the'+'?
Thanks
- Next message: Kalen Delaney: "Re: How to change owner of user datatype?"
- Previous message: Eric Hirst: "Re: Slow performance after restarting"
- In reply to: Adam Machanic: "Re: Question on OpenQuery"
- Next in thread: Adam Machanic: "Re: Question on OpenQuery"
- Reply: Adam Machanic: "Re: Question on OpenQuery"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|