0 Replies Latest reply: Oct 27, 2011 5:26 AM by Marson Alatiit RSS

    Shorter SQL Script

      Hi guys,

       

      do you think its possible to shorten the script below:

       

       

      PERIODS:

      SQL SELECT

               ROW_NUMBER() OVER(ORDER BY "Starting Date" ASC)+1 AS "Row Number",

               "Starting Date",   

               Year("Starting Date") AS PERIODYEAR,

               'P' + CAST(Month("Starting Date" + 15) AS nvarchar) AS PERIODNUM,

               CAST(Year("Starting Date") as nvarchar) + '-P' + CAST(Month("Starting Date" + 15) AS nvarchar) AS PERIODYEARNUM

      FROM db.dbo."Table$Accounting Period";

      INNER JOIN

      SQL SELECT

               ROW_NUMBER() OVER(ORDER BY "Starting Date" ASC) AS "Row Number",

               "Starting Date" - 1 AS "Ending Date"

      FROM db.dbo."Table$Accounting Period";

      STORE PERIODS INTO [qvd\SQL_Periods.qvd];

      DROP TABLE PERIODS;

       

      Thanks/Marson