MSSQL

How To Get The Last Update Of Any Table In MSSQL?

How To Get The Last Update Of Any Table In MSSQL? SELECT OBJECT_NAME ( OBJECT_ID ) AS DatabaseName , last_user_update ,* FROM sys.dm_db_index_usage_stats WHERE database_id = DB_ID ( 'AdventureWorks' ) AND OBJECT_ID = OBJECT_ID ( 'test' )

Get Distinct Maximum Date

Get Distinct Maximum Date Display the latest order of each customers. SELECT A.CustomerID, OrderDate, EmployeeID, ShipperID FROM Orders AS A INNER JOIN (SELECT CustomerID, MAX(OrderDate) AS MaxOrderDate FROM Orders GROUP BY CustomerID) AS B ON A.CustomerID=B.CustomerID AND A.OrderDate=B.MaxOrderDate

SQL Time Difference

Subtracting Date Time in MSSQL --YEAR SELECT DATEDIFF(year, '2012-12-31', '2013-01-01') --Quarter SELECT DATEDIFF(quarter, '2012-01-01 23:59:59', '2013-01-01 00:00:00') --Month SELECT DATEDIFF(month, '2012-12-31 23:59:59.9999999', '2013-02-01 00:00:00.0000000'…

Load More
That is All