Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Update OPENQUERY Issue

Author  Topic 

reddy_vam
Starting Member

43 Posts

Posted - 2009-01-09 : 14:31:50
Hi Guys,
I have a question about using an OPENQUERY with the UPDATE SYNTAX. When i execute the below query i am getting the following error message

declare @PlanCode varchar(6)
UPDATE OPENQUERY(ABC,
'SELECT * FROM ABC01.Package where status_id=1 and PLANNUMBER ='
+char(39)+convert(varchar,@PlanCode)+char(39))
set status_id=3

Error Message: 'Incorrect syntax near '+'. '


Please let me know if any one has any idea on it.

Thanks,
Vamshi

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-09 : 14:39:24
quote:
Originally posted by reddy_vam

Hi Guys,
I have a question about using an OPENQUERY with the UPDATE SYNTAX. When i execute the below query i am getting the following error message

declare @PlanCode varchar(6)
UPDATE OPENQUERY(ABC,
'SELECT * FROM ABC01.Package where status_id=1 and PLANNUMBER =
@PlanCode' )
set status_id=3


Error Message: 'Incorrect syntax near '+'. '


Please let me know if any one has any idea on it.

Thanks,
Vamshi



Go to Top of Page

reddy_vam
Starting Member

43 Posts

Posted - 2009-01-09 : 14:52:01
Thanks for your reply Sodeep, I tried with the above code also, still i am getting the same type of error message.

Thanks,
Vamshi
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-01-09 : 14:57:43
the problem will be the variable handling.

How to pass a variable to a linked server query
http://support.microsoft.com/kb/314520/en-us

hope that helps

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -