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>  

Wednesday, March 18, 2015

Split string using delimiter in sql server


 Create Function [dbo].[SplitString](@String varchar(8000), @Delimiter char(1))  
 returns @temptable TABLE (items varchar(8000),id int)  
 as  
 begin  
 declare @idx int  
 declare @idy int  
 declare @slice varchar(8000)  
 set @idy=1  
 select @idx = 1  
 if len(@String)<1 or @String is null return  
 while @idx!= 0  
 begin  
 set @idx = charindex(@Delimiter,@String)  
 if @idx!=0  
 set @slice = left(@String,@idx - 1)  
 else  
 set @slice = @String  
 if(len(@slice)>0)  
 insert into @temptable(id,Items) values(@idy, @slice)  
 set @idy=@idy+1  
 set @String = right(@String,len(@String) - @idx)  
 if len(@String) = 0 break  
 end  
 return  
 end