Skip to main content

You Can Easily Get the Last Inserted/Updated/Deleted Dates as Follows:

CREATE FUNCTIOn fn_TablesLastUpdateDate(@Date NVARCHAR(20))
RETURNS @table TABLE(TableName NVARCHAR(40), LastUpdated Datetime)
AS
BEGIN
IF(@Date='') OR (@Date Is Null) OR (@Date='0')
BEGIN
    INSERT INTO @table
    SELECT TOP 100 PERCENT TABLENAME,LASTUPDATED FROM 
    (
        SELECT  B.NAME AS 'TABLENAME', MAX(STATS_DATE (ID,INDID)) AS LASTUPDATED
        FROM    SYS.SYSINDEXES AS A
                INNER JOIN SYS.OBJECTS AS B ON A.ID = B.OBJECT_ID
        WHERE   B.TYPE = 'U'  AND STATS_DATE (ID,INDID) IS NOT NULL 
        GROUP BY B.NAME
    ) AS A
    ORDER BY LASTUPDATED DESC
END
ELSE
BEGIN
    INSERT INTO @table
    SELECT TOP 100 PERCENT TABLENAME,LASTUPDATED FROM 
    (
        SELECT  B.NAME AS 'TABLENAME', MAX(STATS_DATE (ID,INDID)) AS LASTUPDATED,
                CONVERT(VARCHAR, MAX(STATS_DATE (ID,INDID)), 103) as Date
        FROM    SYS.SYSINDEXES AS A
                INNER JOIN SYS.OBJECTS AS B ON A.ID = B.OBJECT_ID
        WHERE   B.TYPE = 'U'  AND STATS_DATE (ID,INDID) IS NOT NULL 
        GROUP BY B.NAME
    ) AS A
    WHERE Date=@Date
    ORDER BY LASTUPDATED DESC
END
RETURN
END
-- SELECT * from fn_TablesLastUpdateDate('06/11/2012')

Popular posts from this blog

Dynamics Axapta: Sales Orders & Business Connector

Well, again folllowing my same idea of writting close to nothing and pasting code, I'll paste in some code to create a sales order from some basic data and the invoice it. I'll try to explain more in the future. AxaptaObject axSalesTable = ax.CreateAxaptaObject("AxSalesTable"); AxaptaRecord rcInventDim = ax.CreateAxaptaRecord("InventDim"); AxaptaRecord rcCustTable = ax.CreateAxaptaRecord("CustTable"); rcCustTable.ExecuteStmt("select * from %1 where %1.AccountNum == '" + MySalesOrderObject.CustAccount + "'"); if (MySalesOrderObject.CurrencyCode.Trim().Length == 0) MySalesOrderObject.CurrencyCode = rcCustTable.get_Field("Currency").ToString().Trim(); string sTaxGroup = rcCustTable.get_Field("taxgroup").ToString().Trim(); //set header level fields axSalesTable.Call("parmSalesName", MySalesOrderObject.SalesName.Trim()); axSalesTable.Call("parmCustAccount", M

Passing values between form and class

Class name is EmplDuplication and Form is EmplTable . void clicked() {    MenuFunction mf;    args args = new Args();    ;     args.record(EmplTable);     mf = new menufunction(identifierstr(EmplDuplication), MenuItemType::Action); mf.run(args); } Meanwhile, in the main() method of the EmplDuplication class, we need to put this Axapta x++ code to get the datasource: static void main(Args args) {     EmplDuplication EmplDuplication; EmplTable localEmplTable; ;     if(args.record().TableId == tablenum(EmplTable)) localEmplTable = args.record();     ... }