当需要把数据导入到 带有自增列的主子表的时候,稍显复杂。用以下SQL 实现( ResKey 是主表, ResValue 是子表)

 

--- 有效的 CSM 资源。
select * 
into #t
from dbo.VTxtRes
where [Key]  not in ( select [Key] from PM_VTxtRes )
and [Key] not like  '%.0' 
and  [Key] not like 'MyOql.ProductTypeEnum.%'
and [Key] != 'MyOql.EmptyEnum.选择类型'
and [Value] is not null
order by Value
 
 
select 
'insert into ResKey ( [Key]  ) values ( ''' + [Key] + ''');  insert into ResValue (Lang,ResID,[Value]) values ( ' + cast( Lang as varchar(20))  + ' ,SCOPE_IDENTITY(), ''' + [Value] + ''' ) ;'
from #t

 

将会生成:

insert into Res_Key ( [Key] ) values ( 'MyOql.TaskVistLevelEnum.Level1'); insert into Res_Value (Lang,ResID,[Value]) values ( 2 ,SCOPE_IDENTITY(), '1' ) ;

此方法具有一定通用性,作为记录。

相关文章:

  • 2021-06-28
  • 2021-12-11
  • 2021-12-03
  • 2022-12-23
  • 2021-07-11
  • 2021-12-25
  • 2021-11-27
猜你喜欢
  • 2022-01-02
  • 2021-06-10
  • 2022-12-23
  • 2021-12-14
  • 2018-10-24
  • 2021-08-19
  • 2021-10-13
相关资源
相似解决方案