表结构更改后或新增加数据后同步到表中

select 'insert into mtx_system_module(module_id,module_code,module_name,module_note,create_date,version)values('
+cast(moduleid as varchar(10))+','''+ObjectID+''','''+Name+''','''+isnull(Note,'')+''',NOW(),1);' from AppModules
 where subsystem=1 and ParentModuleID is not null
 
 -----------------------------------------------
select 'insert into mtx_app_module(module_id,parent_module_id,version)values('
+cast(moduleid as varchar(10))+','+
case ParentModuleID when 1 then 'NULL' else cast(ParentModuleID as varchar(10)) end
+',1);' from AppModules
 where subsystem=1 and ParentModuleID is not null
 
 ----
 select * 
 from AppModules
 where subsystem=1 and ParentModuleID is not null

原文地址:https://www.cnblogs.com/mmnyjq/p/3912985.html