home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 32 / IOPROG_32.ISO / SOFT / SqlEval7 / devtools / samples / MSDTC / tsql / chgaddr.sql next >
Encoding:
Text File  |  1997-04-09  |  799 b   |  35 lines

  1. Use Pubs
  2. GO
  3.  
  4. if exists (select * from sysobjects where id = object_id('dbo.change_addr') and sysstat & 0xf = 4)
  5.     drop procedure dbo.change_addr
  6. GO
  7.  
  8. CREATE PROCEDURE change_addr(@au_id varchar(11), @addr varchar(40), @toserver varchar(12) ) AS
  9.  
  10. declare @execstr varchar(200)
  11.  
  12. -- 1. Start a DTC Transaction
  13.  
  14. BEGIN DISTRIBUTED TRAN
  15.  
  16. -- 2. Change local author information
  17.  
  18. update authors set address = @addr where au_id = @au_id 
  19.  
  20. -- 3. Make a string with the server name, procedure to execute and parameters
  21. select @execstr = @toserver + '.pubs..update_addr ' 
  22.  
  23.  
  24. -- 4. Update remote server
  25. --    NOTE THAT THIS SERVERS MUST BE ADDED TO EACH OTHER VIA sp_addserver and sp_addremotelogin
  26.  
  27. exec @execstr @au_id, @addr
  28.  
  29. -- 5. Commit the DTC transaction
  30.  
  31. COMMIT TRAN
  32. GO
  33.  
  34.  
  35.  
  36.