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.
Author |
Topic |
Kyle Doouss
Yak Posting Veteran
64 Posts |
Posted - 2014-11-28 : 10:09:17
|
I would very much appreciate if someone could help me to write this query so that I can pass a variable (from a cursor) for the were ORDER_ID =.UPDATE OPENQUERY ([DISPATCHER_LIVE], 'select * from DCSDBA.ORDER_HEADER where ORDER_ID = ''405119-RM18''')SET CONSIGNMENT = 'UNROUTED' |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-11-28 : 10:21:00
|
Build the update command as an nvarchar variable then execute it using sp_executesql |
|
|
Kyle Doouss
Yak Posting Veteran
64 Posts |
Posted - 2014-11-28 : 11:23:32
|
Thanks.. I have sortedcode belowDECLARE @remotesql nvarchar(4000), @localsql nvarchar(4000), @order_id varchar(20)set @order_id = '405119-RM18'set @localsql = 'UPDATE OPENQUERY ([DISPATCHER_LIVE], ''select * from DCSDBA.ORDER_HEADER where ORDER_ID = '''''+@order_id+''''''')SET CONSIGNMENT = ''UNROUTED'''EXEC sp_executesql @localsql |
|
|
|
|
|