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 |
|
tleonard
Starting Member
13 Posts |
Posted - 2008-09-23 : 10:50:23
|
| This works.Select @edit = SORDNO, @cadd = SAVSADDR from flp612 where status = 'P'where flp612 is table in local database I want to change flp612 to point to the table on the linked serverCCTRANS. FYI.. the linked server is an iSeries (AS400)This is how I coded it, but get error msg when clicking <Check Syntax>.Select * from openquery([cctrans], 'Select @edit = SORDNO, @cadd = SAVSADDR from flp612 where STATUS = ''P''')Error 7321: An error occurred while preparing a query for execution against OLE DB provider 'MSDASQL'.SQL0104 - Token = was not valid. Valid tokens: + - AS <IDENTIFIER>.OLE DB error trace [OLE/DB Provider 'MSDASQL' ICommandPrepare::Prepare returned 0x80040e14].tl |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-09-23 : 11:05:48
|
| Those variables are out of scope within the context of the SQL statement executed via openquery. You need to set those variable on the outside, within the scope of your T-SQL statement, like this:Select @edit=edit, @cadd=caddfrom openquery([cctrans], 'Select SORDNO as edit, SAVSADDR as cadd from flp612 where STATUS = ''P''')- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
tleonard
Starting Member
13 Posts |
Posted - 2008-09-23 : 14:15:55
|
| That worked! Thanks.tl |
 |
|
|
sunsanvin
Master Smack Fu Yak Hacker
1274 Posts |
Posted - 2008-09-23 : 16:59:16
|
| anyway that is not linked server.ArnavEven you learn 1%, Learn it with 100% confidence. |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-09-23 : 17:04:21
|
| sunsanvin,Openquery also Uses Linked Server. |
 |
|
|
|
|
|