Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Update linked server


Update linked server

Author
Message
e000911
e000911
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 223
Hi

i have linked server called TESTdata

with coloumn id which is varchar datatype that contain number .

i want to update the last recourd with +1 .


DECLARE @CR_num TABLE (
NUM varchar(50) )

declare @NUM as varchar(50)

select @NUM=convert(int,[CCFNUM_LASTNUM_00N])+1 from [TEST_DATA].[***].[dbo].[CCFNUM] where [CCFNUM_LOCATION_00N]='9999'

update [TEST_DATA].[***].[dbo].[CCFNUM] set [CCFNUM_LASTNUM_00N]=(select @NUM) where [CCFNUM_LOCATION_00N]='9999'





but i get this error :

OLE DB provider "*****" for linked server "TEST_DATA" returned message " Ambiguous table reference: (CCFNUM)
UPDATE << Syntax Error >> CCFNUM SET CCFNUM_LASTNUM_00N = ?

WHERE CCFNUM_LOCATION_00N = ? AND CCFNUM_LASTNUM_00N
".
Msg 7343, Level 16, State 4, Line 5
The OLE DB provider "****" for linked server "TEST_DATA" could not UPDATE table "[TEST_DATA].[****].[dbo].[CCFNUM]".

===========
but
when i update wit this command :

update [TEST_DATA].[****].[dbo].[CCFNUM] set [CCFNUM_LASTNUM_00N]=1515 where [CCFNUM_LOCATION_00N]='9999'


it run successfully ???!!!


any suggesting ?

regards,,,,
HanShi
HanShi
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3049 Visits: 3633
I think it is related to the datatype of the variable. If the columntype is INT the variable must be implicitly converted from the VARCHAR type.
If the value is always a number, why have you declared it as a VARCHAR and not as an INT?

** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
e000911
e000911
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 223
The destination datatype is varchar and we can't change it.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search