Monday, 12 November 2007

HTML: Auto Adjust IFRAMEs

Auto Adjust IFRAME
------------------
<iframe name="ifr" id="ifr" src="whatever.html" onload="this.style.height 
= ifr.document.body.scrollHeight + 5"></iframe> 

OR

<iframe id="ifr" src="ifr.html">< /iframe>< br />
<input type="button" onclick="document.getElementById('ifr').style.height 
= ifr.document.body.scrollHeight + 5" value="Ajust" />

Sunday, 30 September 2007

TSQL: Delete duplicate rows which have the same primary key

--Delete Duplicate Rows
set rowcount 1
delete from hrerequestforapproval
where hrerequestforapprovalid=40508508

TSQL: Get Duplicate Rows Count

--Get Duplicate Row Counts
SELECT hrerequestforapprovalid, count(*)
FROM hrerequestforapproval
GROUP BY hrerequestforapprovalid
HAVING count(*) > 1

Friday, 24 August 2007

HTML: Mailto with CC, Subject, Body prepopulated

<a href="mailto:your.nominateduser@yahoo.com.au?cc=your.nominateduser@yahoo.com.au&subject=A new request&body=Please kindly complete the details below:%0D%0A%0D%0AName:%0D%0ATitle:%0D%0ALocation:%0D%0APhone:%0D%0AMobile:%0D%0A">Click here to email</a>

Wednesday, 15 August 2007

Javascript: Replacing OnLoad attribute in Body tag

//This section runs the SetPage function when the form loads - replaces OnLoad function in body tag
addLoadEvent(SetPage);
function addLoadEvent(func) {   
   var oldonload = window.onload;   
   if (typeof window.onload != 'function') {   
     window.onload = func;   
   } else {   
     window.onload = function() {   
       oldonload();   
       func();   
     }   
  }   
}

//Another example will run when page load but code doesn't utilize onLoad attribute in body tag
var frm = document.frmCreateModifyPosition;
window.onload = function(){
if (frm.txtAction[1].checked){
ShowPositionID()
}
}

Wednesday, 21 March 2007

TSQL: ALTER TABLE

--Alter table
ALTER TABLE MyTable ALTER COLUMN NullCOl NVARCHAR(20) NOT NULL
ALTER TABLE doc_exa ADD column_b VARCHAR(20) NULL
ALTER TABLE doc_exb DROP COLUMN column_b
ALTER TABLE doc_exc ADD column_b VARCHAR(20) NULL CONSTRAINT exb_unique UNIQUE
ALTER TABLE doc_exd WITH NOCHECK ADD CONSTRAINT exd_check CHECK (column_a > 1)

Friday, 9 March 2007

TSQL: UPDATE from values across server via Linked Server

You'll need to setup a linked server first in Enterprise Manager. This is found under Security > Linked Servers. Right click and select "New Linked Server", follow prompts to complete.


Update Dest
SET helpdefinitiontext = T.helpdefinitiontext
From
[erokwis99\dev].mis.dbo.measure as Dest Join
mis.dbo.measure as T On
Dest.measureid = T.measureid