如果数据库AA_data同BB_data在同一台服务器192.168.0.201上的话,我测试使用如下语句可以实现我的需求。 CREATE PROCEDURE [PR_aa_to_bb] @table_name char(10), @field_id char(10), @lc_add1_edit2_del3 char(1) AS begin --@table_name ID字段名称;@field_id ID号; @lc_add1_edit2_del3 1新增2修改3删除 if @table_name = 'my_table' begin if @lc_add1_edit2_del3 = '1' begin INSERT INTO BB_data.dbo.my_table(id_no, mingch, shul, danj, bb) select id_no, mingch, shul, danj, bb from AA_data.dbo.my_table a where id_no = rtrim(ltrim(@field_id)) end else if @lc_add1_edit2_del3 = '2' begin update b SET mingch = a.mingch, shul = a.shul, danj = a.danj, bb = a.bb from AA_data.dbo.my_table a left outer join BB_data.dbo.my_table b on a.id_no = b.id_no where a.id_no = rtrim(ltrim(@field_id)) end else if @lc_add1_edit2_del3 = '3' begin delete BB_data.dbo.my_table where id_no = rtrim(ltrim(@field_id)) end end end GO