Tuesday, April 14, 2015

Insert value from one table to another in SQL Server

Example

 INSERT INTO new_table (Col1, Col2, Col3, Coln)  
 SELECT Value1, Value2, Value3, Valuen
 FROM initial_table  
 -- optionally WHERE / JOINS ...  

Update one table based on another table using JOIN - SQL Server

Example

  UPDATE t1 SET   
     t1.status = 1  
  FROM  table1 t1   
     INNER JOIN table t2   
           ON t1.Id = t2.ID  
  WHERE t2.num = 15   

Sunday, April 12, 2015

When restoring a backup, how do I disconnect all active connections? SQL Server

SQL Server Management Studio 2008

The interface has changed for SQL Server Management studio 2008, here are the steps 

  1. Right-click the server in Object Explorer and select 'Activity Monitor'.
  2. When this opens, expand the Processes group.
  3. Now use the drop-down to filter the results by database name.
  4. Kill off the server connections by selecting the right-click 'Kill Process' option.

Thursday, April 9, 2015

Create a Pop-up div on Mouse hover in jQuery

Script


 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>  
   <script type="text/javascript">  
    $(function() {  
     var moveLeft = 20;  
     var moveDown = 10;  
     $('a#trigger').hover(function(e) {  
      $('div#pop-up').show();  
      //.css('top', e.pageY + moveDown)  
      //.css('left', e.pageX + moveLeft)  
      //.appendTo('body');  
     }, function() {  
      $('div#pop-up').hide();  
     });  
     $('a#trigger').mousemove(function(e) {  
      $("div#pop-up").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);  
     });  
    });  
   </script>  

CSS


   <style type="text/css">  
      div#pop-up {  
     display: none;  
     position: absolute;  
     width: 280px;  
     padding: 10px;  
     background: #eeeeee;  
     color: #000000;  
     border: 1px solid #1a1a1a;  
     font-size: 90%;  
    }  
   </style>  

Desigin


  <a href="#" id="trigger">Here is my popup</a>  
 <div id="pop-up">  
    <h3>Pop-up div Successfully Displayed</h3>  
    <p>  
     This div only appears when the trigger link is hovered over.  
     Otherwise it is hidden from view.  
    </p>  
   </div>