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!

Dynamic openquery - lost in the quotes!

Status
Not open for further replies.

northrd

Programmer
May 18, 2003
74
AU
I have a mssql 2005 database with a linked server to a FoxPro9 database. As you can see below I just want to dynamically construct an openquery.

Please help or direct me.
Thanx

Fetch Next from OOS into @OrderDate, @Company, @DrugCode, @Message, @QtySupplied, @QtyOrdered
While @@Fetch_Status = 0
Begin
if @qtysupplied = @qtyordered
select * from openquery([fred], 'delete from drugnote where dntcode="' + @DrugCode + '"')
else
set @OOSMessage = @Message + ' from ' + @Company + ' on ' + @OrderDate
select * from openquery([fred], 'update drugnote set dntnote="{\rtf1\ansi\ansicpg1252\deff0\deflang3081{\fonttbl{\f0\fnil\fcharset0 Arial;}} \viewkind4\uc1\pard\b\' + @OOSMessage + ' \b0\fs20 \par }" where dntcode="' + @DrugCode + '"')
end
Fetch Next from OOS into @OrderDate, @Company, @DrugCode, @Message, @QtySupplied, @QtyOrdered
END

Close OOS
Deallocate OOS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top