我将在SQL Server 2014中使用MERGE表在目标表中插入行.我想在目标表中自动增量ID列.
CREATE TABLE #targetTable(id int,name varchar(50))
CREATE TABLE #sourceTable(id int,name varchar(50))
INSERT INTO #sourceTable values(1,'John');
INSERT INTO #sourceTable values(1,'Albrt');
INSERT INTO #sourceTable values(1,'Roy');
MERGE #targetTable AS [target]
USING #sourceTable AS [source]
ON [target].id = [source].id
WHEN NOT MATCHED THEN
INSERT (id, Name)
VALUES ((select isnull(max(id),1) + 1 from #sourceTable), source.Name);
select * from #targetTable as T
drop table #targetTable
drop table #sourceTable
Run Code Online (Sandbox Code Playgroud)
我试过这样做,select isnull(max(id),1) + 1 from #sourceTable但它给所有列提供了相同的ID.这个将返回到输出以下
2 John
2 Albrt
2 Roy
Run Code Online (Sandbox Code Playgroud)
输出需要像
2 …Run Code Online (Sandbox Code Playgroud) How to remove list items from list1 which mats condition with list2 items using LINQ without duplicates
I know how to do it in simple foreach way but i want the same using Linq style single line code.
How to do it using Linq?
Input list
list1 = new List(){new object{id = 40},new object{id = 50},new object{id = 60}}
list2 = new List(){new object{id = 400},new object{id = 50},new object{id = 600}}
Run Code Online (Sandbox Code Playgroud)
Expected Output should from
list1
new object{id …
有没有办法通过 webhdfs REST API 检查 HDFS 路径上是否存在某些同名文件?
我的示例网址:
http://my-sample-url:port/webhdfs/v15/tmp/mydata/sample.txt?op=CREATE&user.name=john&namenoderpcaddress=prodaddress&createflag=&createparent=true&overwrite=false
Run Code Online (Sandbox Code Playgroud)
我正在通过 HTTPClient 应用程序调用此 API。如何检查该 hdfs 路径上是否存在同名文件,以便我可以决定进一步处理?
我正在寻找单行解决方案。