New answers tagged row
I finally worked around the problem using SQL Server 2012 sequences. Unfortunately, this won't work with versions prior to 2012. Speed was o.k, one or two minutes for about 20 million IDs to insert. declare @old_max_id int -- get somehow declare @sql nvarchar(2000) set @sql=N'CREATE SEQUENCE INSERT_IDS START WITH ' + str(@old_max_id + 1) + N' INCREMENT BY ...
This is standard sql server emulation of GROUP_CONCAT in mysql select SalesOrderNumber,Ids=Stuff((SELECT ',' + CAST(SalesOrderDetailID as VARCHAR(255)) FROM t t1 WHERE t1.SalesOrderNumber=t.SalesOrderNumber FOR XML PATH ('')) , 1, 1, '' ) from t GROUP BY SalesOrderNumber Fiddle Also,you might be intrested in ...
Unfortunately, there is no provision in SQL syntax to say "all columns except this one column". You can achieve your goal by spelling out the remaining list of columns in row type syntax like this: SELECT a.id, a.name, json_agg((b.col1, b.col2, b.col3)) as "item" FROM a JOIN b ON b.item_id = a.id GROUP BY a.id, a.name;
Top 50 recent answers are included