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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error abt remote table & linked server

Status
Not open for further replies.

JJ26

Programmer
Oct 22, 2002
85
ID
somebody can help me ??

i run the following script in server SEREIS
Code:
create proc sp_transfer_scCompany
as
declare @brcode numeric, @brnm varchar(50), @jml numeric (5,0)
declare mycur  Cursor for 
	select branch_code, branch_name from [it-6].security.dbo.sc_company where branch_code =52

open  mycur 
fetch next from mycur into @brcode, @brnm

While @@fetch_status =0
begin
	select @jml =count(*) from eis.dbo.sc_company where branch_code = @brcode
	if (@jml =0)
	begin
		insert into eis.dbo.sc_company (branch_code,branch_name)
		values (@brcode, @brnm)
		select 'insertig..'
	end	
	else
	begin
		select '****'
	end
	fetch next from mycur into @brcode
end
close mycur
deallocate mycur

as you can see in the script, i try to select a table which i've linked i.e. IT-6

when i execute those scripts, it run successfully by inserting 1 row (since there's no record in sereis.eis.dbo.sc_company)
But i got this error :
[red]
Remote tables are not updatable. Updatable keyset-driven cursors on remote tables require a transaction with the REPEATABLE_READ or SERIALIZABLE isolation level spanning the cursor.

(1 row(s) affected)


(1 row(s) affected)

Server: Msg 16924, Level 16, State 1, Procedure sp_transfer_scCompany, Line 24
Cursorfetch: The number of variables declared in the INTO list must match that of selected columns.
[/red]

Thanks alot....
 
First question: why are you using a cursor to do this?? It certainly doesn't look like you need one.

Secondly, I don't quite understand the logic here. Your cursor is only ever selecting branch_code 52 so your IF statement in the loop will always be the same.

Can you explain what you are trying to do and I'm sure we can suggest a more efficient set-based solution?

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top