Wednesday, February 26, 2014

SSIS: Derived Column

Add in Expression column
If single if else
(Active ==  0  ? "IAmNotActive" : "IamActive")
Where active is column name.

Second when you have multiple account:

(Age< 20 ? 1 :
(Age>= 20 && Age< 30 ? 2 :
(Age>= 30 && Age< 40 ? 3 :
(Age>= 40 && Age< 50 ? 4 :
5))))

means if (Age< 20){1}
else if (Age>= 20 && Age< 30) {2}
else if (Age>= 30 && Age< 40) {3}
else if (Age>=  40 && Age< 50 ){4}
else {5}
Where Age is column name

Wednesday, February 19, 2014

Prevent table row onclick event to fire when clicking button inside the row

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   <script type="text/javascript">
      function test(e) {
         alert('button');
         e.stopPropagation();
      }
   </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <table border="1" cellpadding="0" cellspacing="0">
          <tr onclick="javascript:alert('li')" style="cursor:pointer">
             <td>
             <input  type="button" onclick="test(event)" value="click me" />
             </td>
             <td>ll</td>
          </tr>
       </table>
    </div>
    </form>
</body>
</html>

Friday, February 7, 2014

SQL Update table column if parameter has value in sigle update statement



CREATE TABLE test2(clm1 INT,clm2 INT)

INSERT INTO test2 VALUES(1,1)
INSERT INTO test2 VALUES(2,2)
INSERT INTO test2 VALUES(3,3)
INSERT INTO test2 VALUES(4,4)


DECLARE @par1 INT = 100;
DECLARE @par2 INT = NULL;

UPDATE test2
SET clm1 = COALESCE(@par1,clm1)
,clm2 = COALESCE(@par2,clm2)

WHERE clm1 = 1

SELECT * FROM test2

DROP TABLE test2