Retrieving JVM Settings through code

No Comments

The following code retrieves Free Memory, Total Memory, Max Memory allocated to JVM

Runtime runtime = Runtime.getRuntime();
System.out.println(“max memory: ” + runtime.maxMemory() / (1024.0*1024.0));
System.out.println(“allocated memory: ” + runtime.totalMemory() / 1024);
System.out.println(“free memory: ” + runtime.freeMemory() / 1024);

Sharepoint Foundation 2010 – Changing Master Page

No Comments

Changing master page is similar to WSS 3.0. There is no link from the UI. We need to change it in Sharepoint designer or some other client.
From the sharepoint designer,
1. Select the desired master page
2. Right click and select Set as Default Master page

Unpack msi package

No Comments

msi package is like a normal package where we can unpack using some command line tools available in the OS

To unpack msi package, use the following command

msiexec /a mypackage.msi /qb TARGETDIR=”C:\MyFolder”

Sharepoint 2010 – Product key invalid

No Comments

When we upgrade sharepoint 2010 from beta or upgrade sharepoint server 2010 from foundation or re-installing sharepoint server 2010, Product key invalid may displayed in the setup screen even though we entered correct key.

To resolve this remove the setup cache folder which is @ C:\Program Files (x86)\MSECache\oServer

Calling Javascript in XForm

No Comments

We can call javascript from XForm using xform:load tag. The following example calls the javascript function named helloscript.

      <xforms:trigger>
        <xforms:label>Launch JS</xforms:label>
        <xforms:load resource="javascript:helloscript()" ev:event="DOMActivate"/>
      </xforms:trigger>

Find Largest table by Row count – SQL server 2005

No Comments

USE AdventureWorks

GO
SELECT OBJECT_NAME(OBJECT_ID) TableName, st.row_count
FROM sys.dm_db_partition_stats st
WHERE index_id < 2
ORDER BY st.row_count DESC
GO


Remove alphabets – Formula field in crystal reports

No Comments

The following formula field removes alphabets

StringVar MyField;

StringVar Strip;

Strip:= “”;

MyField := {Command.xxx};

While Length(MyField) > 0

Do

(

If IsNumeric(Left(MyField,1))

Then Strip := Strip + Left(MyField,1)

Else

If (Left(MyField,1)=”-”)

Then Strip := Strip + Left(MyField, 1);

MyField:= Mid(MyField,2);

);

Strip;

Delete SQL Log file

No Comments

Sometimes, we just do not need the big log file. For example, I have a 40GB log file. I am sure I do not need this log file and want to get rid of it completely to free up the hard drive space. The logic is:

Detach the database
Rename the log file
Attach the database without the log file
Delete the log file
Let’s say, the database name is testDev. In the SQL Server Management Studio,

Highlight the database-> Tasks->Detach..-> Click OK
Go to log file folder -> rename the testDev_log.ldf to be like testDev_log-aa.ldf
Highlight Databases->Attach…-> Click Add -> add the database testDev, highlight the log file and click the ‘Remove’ button. This means you only attach testDev.mdf
After this is done, you can verify the contents of the attached database and then delete the log file

Extracted from http://www.codeproject.com/KB/database/truncate_log_SQL_server.aspx

Sign out from gmail remotely

No Comments

We can sign out form gmail remotely if we have any sessions opened at other locations. To release all the sessions
1. Login to gmail
2. Scroll to the bottom
3. Click on the Details link at Last account activity
4. Click sign out all other sessions in the dialog box

Getting tables size SQL server

No Comments

The following SQL query returns the size of each table in the specified database.

USE

sp_MSforeachtable @command1=’EXEC sp_spaceused ”?”’,@whereand=’or OBJECTPROPERTY(o.id, N”IsSystemTable”) = 1′

Older Entries