declare @SqlStr as nvarchar(max)
  set @SqlStr=N'Merge Into [Categories] t 
  USING(VALUES (9,''rice'',''main food'',null))
  AS s ([CategoryID],[CategoryName],[Description],[Picture])
  on t.[CategoryID]=s.[CategoryID]
  When Matched Then Update Set t.[CategoryName]=s.[CategoryName],
                               t.[Description]=s.[Description],
                               t.[Picture]=s.[Picture]
  When Not Matched Then Insert ([CategoryName],[Description],[Picture])
                        values(s.[CategoryName],s.[Description],s.[Picture]);'
  exec sp_executesql @SqlStr 
View Code

相关文章:

  • 2021-08-30
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2022-02-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-31
  • 2021-06-12
  • 2021-04-11
相关资源
相似解决方案