SqlServer Merge AddOrUpdate data

merge TableName as target using( values(‘FIELDVALUE1‘,‘FIELDVALUE2‘)) as source (FIELDNAME1,FIELDNAME2) on target.FIELDNAME1= source.FIELDNAME1 when matched then update set FIELDNAME2= source.FIELDNAME2 when not matched then insert (FIELDNAME1,FIELDNAME2) values (source.FIELDNAME1,source.FIELDNAME2);
  这是用SqlServer 的MERGE来实现AddOrUpdate功能的

时间: 2024-11-03 03:27:23

SqlServer Merge AddOrUpdate data的相关文章

sqlserver MERGE INTO 用法

declare @pin varchar(20),@yearStr varchar(20) set @pin='01082118' set @yearStr='2017' MERGE INTO zk_yj_manage AS a USING (select @pin as 'pin',@yearStr as 'yearStr' ) AS b ON (a.pin= b.pin and a.yearStr = b.yearStr ) WHEN MATCHED THEN UPDATE SET base

sqlserver merge into

create table #ttt(id int,name nvarchar(10));merge into #ttt t using (select 1 as id ,'eee' as name ) b on (t.id = b.id) when matched then update set t.name = b.name when not matched then insert(id,name) values(b.id,b.name); select * from #ttt; merge

Merge compare columns when null

Key words: merge compare columns when we contact merge sql in ETL, When we update some columns we should compare the value change or not. We always write coalesce(columnname,valueifnull)<>coalesce(columnname,valueifnull) But we should take care of t

[转]SQLSERVER一些公用DLL的作用解释

转自:Leo_wlCnBlogs SQLSERVER一些公用DLL的作用解释 如果你的SQLSERVER安装在C盘的话,下面的路径就是相应SQLSERVER版本的公用DLL的存放路径 SQL2005 C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies\ SQL2008 C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\ SQL2012 C:\Program Files\Mi

R语言合并data.frame

Merging Data Adding Columns To merge two data frames (datasets) horizontally,  use the merge function. In most cases, you join two data frames  by one or more common key variables (i.e., an inner join). # merge two data frames by ID   total <- merge(

data cleaning

Cleaning data in Python Table of Contents Set up environments Data analysis packages in Python Clean data in Python Load dataset into Spyder Subset Drop data Transform data Create new variables Rename variables Merge two datasets Handle missing value

找不到请求的 .Net Framework Data Provider。可能没有安装.

找不到请求的 .Net Framework Data Provider.可能没有安装. 解决方法: 安装Microsoft SQL Server Compact 4.0. 安装Microsoft SQL Server Compact 4.0之后,程序运行正常. 问题的原因就是程序连接.sdf的数据库时的报错,所以安装Microsoft SQL Server Compact 4.0即可. Microsoft SQL Server Compact 4.0中文版下载地址: http://www.mic

连接MySQL数据库得到错误&ldquo;Unable to find the requested .Net Framework Data Provider&rdquo;

  Registering DbProviderFactories Each .NET Framework data provider that supports a factory-based class registers configuration information in the DbProviderFactories section of the machine.config file on the local computer. The following configurati

[Coursera] Getting and Cleaning Data Quiz

Quiz 1 Question 1 The American Community Survey distributes downloadable data about United States communities. Download the 2006 microdata survey about housing for the state of Idaho using download.file() from here: https://d396qusza40orc.cloudfront.