Posts

Clear SQL Server Cache

When perform benchmark testing, make sure you need to clean the SQL server cache in order to have a more accurate result. -- Clean all data in the cache DBCC DROPCLEANBUFFERS -- clean cache from stored procedure DBCC FREEPROCCACHE

Display the size of all tables in SQL Server 2005

SET NOCOUNT ON DBCC UPDATEUSAGE(0) -- DB size. EXEC sp_spaceused -- Table row counts and sizes. CREATE TABLE #t ( [name] NVARCHAR(128), [rows] CHAR(11), reserved VARCHAR(18), data VARCHAR(18), index_size VARCHAR(18), unused VARCHAR(18) ) INSERT #t EXEC sp_msForEachTable 'EXEC sp_spaceused ''?''' SELECT * FROM #t -- # of rows. SELECT SUM(CAST([rows] AS int)) AS [rows] FROM #t DROP TABLE #t

Windows Server 2008 64bit Edition SMTP service logging

In Windows Server 2008 64bit edition, SMTP service isn't log even if you enabled the logging. It is found that  you need to install the ODBC Logging module. Install ODBC Logging module (Server Manager > Roles > Web Server (IIS) > Add Role Services > Health and Diagnostics > ODBC Logging) Stop / Start the SMTP Service Verify your SMTP service is configured for logging.  It's not on by default. Try a local telnet test (assuming the telnet client is installed) Look at your log folder. Or, take a look at this from Steve Schofield's blog :

Change SQL Server from Windows authentication to Mixed Mode

Image
Connect to your server. In Object Explorer, right-click the server, and then click Properties. On the Security page, select SQL Server and Windows Authentication mode. Restart the SQL Server service.

Send message or alert to all online users

In Axapta 2.5 or 3.0, there is a standard function to send message to all online users. But it has been taken away after AX 4.0. However you still do this by some codes: static void sendAlertToOnlineUsers(Args _args) { EventInbox inbox; EventInboxId inboxId; SysClientSessions sessions; ; while select sessions where sessions.Status == SessionState::Running { inboxId = EventInbox::nextEventId(); inbox.initValue(); inbox.ShowPopup = NoYes::Yes; inbox.Subject = "GIT TESTING ALERT MESSAGE"; inbox.Message = "HELLO?"; inbox.SendEmail = false; inbox.UserId = sessions.userId; inbox.InboxId = inboxId; inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime(); inbox.insert(); } }

SQL script to truncate and shrink log file of all database

This is a quick method to truncate and shrink the log file of all database. I usually use for clean up development database. declare @ssql nvarchar(4000) set @ssql= ' if ''?'' not in (''tempdb'',''master'',''model'',''msdb'') begin use [?] declare @tsql nvarchar(4000) set @tsql = '''' declare @iLogFile int declare @sLogFileName varchar(55) declare LogFiles cursor for select fileid from sysfiles where status & 0x40 = 0x40 open LogFiles fetch next from LogFiles into @iLogFile while @@fetch_status = 0 begin set @tsql = @tsql + ''DBCC SHRINKFILE(''+cast(@iLogFile as varchar(5))+'', 500) '' fetch next from LogFiles into @iLogFile end set @tsql = ''USE [?]; '' + @tsql + '' BACKUP LOG [?] WITH TRUNCATE_ONLY '' + @tsql --print @tsql --for debugging exec(@tsql) close LogFiles DEALLOCATE LogFiles end' exec sp_msforeachdb @ss...

What images are available for the NormalResource Property

It is under: Microsoft Dynamics AX menu > Tools > Development tools > Embedded resources. The window displays the available images, and the Resource ID of each image.