lunes, 18 de mayo de 2015

An approach like IDENTITY(INT,1,1) FOR TEMP TABLE IN SQL AZURE AND SQL 2014

Some times we need to add an ID for a rowset in SQL Server, the most common way to do it is by using a temp table, but for SQL Azure and SQL Server 2012 and 2014 the SELECT .. INTO.. clause can not be execute, so we have to use the ROW_NUMBER() OVER clause instead. The effect of GETDATE() and the COL1 and COL2 fields will get a unique key.


CREATE TABLE #NO_DEDUCIBLE (
ID INT NULL,
[CUENTA] VARCHAR(50) NULL,
[TOTAL_DEDUCIBLE] FLOAT NULL,
[TOTAL_NODEDUCIBLE] FLOAT NULL,
[ES_GASTO] INT NULL
)



INSERT INTO #NO_DEDUCIBLE
SELECT
ROW_NUMBER() OVER (ORDER BY GETDATE(), COL1, COL2 ) ID,
                        COL1,
                        COL2,
@CUENTA_NODEDUCIBLE [CUENTA],
sum(DCOM.NODEDUCIBLE) TOTAL_DEDUCIBLE,
0 TOTAL_NODEDUCIBLE,
1 ES_GASTO
FROM
...

WHERE DCOM.COMPROBACIONID = @COMPROBACIONID
                 GROUP BY COL1, COL2

Transacciones Fiori

  /UI2/CACHE Register service for UI2 cache use /UI2/CACHE_DEL Delete cache entries /UI2/CHIP Chip Registration /UI2/CUST Customizing of UI ...