What's up!

Pyaarey Allah!

Wednesday, March 5, 2014

SQL Server - Kill process attached to database

0 comments

If you are trying to run a command


And you can't get access to the database because database might be in use by the single user and is in the single user mode.

There is a work around.

Run This command


SP_Who will show you processes attached to your database. See DBNAME Column and find your database in it. Then note down SPID. For example 72 is the SPID of the process you want to kill.
Then run this command to kill the process.

Kill command will kill the process. And then you will be able to run Set multi user mode command again and it should work.

Saturday, February 8, 2014

Shrink database and check its progress

0 comments

Claiming space from a SQL Server database is not like deleting all rows from a table or truncate it. Please follow the instructions if you want to reclaim your disk space.

  1. Run Sql Command:
    DBCC SHRINKDATABASE (MyDBName, 10 )
    Here MyDBName is a valid database name and 10 is the percentage of reserved free space.
  2. Run following command to check percentage done:
    select percent_complete, total_elapsed_time, estimated_completion_time, * from sys.dm_exec_requests where command = 'DbccFilesCompact'

Monday, October 14, 2013

Husool ka pehla usool

0 comments

Husool ka pehla usool be-nyazi hai

Sunday, October 6, 2013

Got a new PC

0 comments

I got a new desktop PC with
Intel 4th Gen Processor Intel Core i7 4770-k 3.5GHZ
Asus Z87-Pro MotherBoard
2 x 8GB-1600 Corsair Memory sticks
2 x Samsung SSDs(540 mbps) Raid0 for Windows, 250GB Each
2 x 1TB WD Black Disks for critical data storage raid-1 SATA III
1 x 1TB WD SATA 1 for media files
CoolerMaster Casing
H100i Extreme performance Liquid Cooling unit
Ex 2 Extreme 650Watts Power Supply
Nvidia Gforce 650Ti Boost Graphics Card 2GB DDR5

Sunday, September 1, 2013

Include jqeury bookmarklet

0 comments




    (function() {
      var el=document.createElement('div'),
          b=document.getElementsByTagName('body')[0],
          otherlib=false,
          msg='';
      el.style.position='fixed';
      el.style.height='32px';
      el.style.width='220px';
      el.style.marginLeft='-110px';
      el.style.top='0';
      el.style.left='50%';
      el.style.padding='5px 10px';
      el.style.zIndex = 1001;
      el.style.fontSize='12px';
      el.style.color='#222';
      el.style.backgroundColor='#f99';
     
      if(typeof jQuery!='undefined') {
        msg='This page already using jQuery v'+jQuery.fn.jquery;
        return showMsg();
      } else if (typeof $=='function') {
        otherlib=true;
      }
     
      // more or less stolen form jquery core and adapted by paul irish
      function getScript(url,success){
        var script=document.createElement('script');
        script.src=url;
        var head=document.getElementsByTagName('head')[0],
            done=false;
        // Attach handlers for all browsers
        script.onload=script.onreadystatechange = function(){
          if ( !done && (!this.readyState
               || this.readyState == 'loaded'
               || this.readyState == 'complete') ) {
            done=true;
            success();
            script.onload = script.onreadystatechange = null;
            head.removeChild(script);
          }
        };
        head.appendChild(script);
      }
      getScript('http://code.jquery.com/jquery.min.js',function() {
        if (typeof jQuery=='undefined') {
          msg='Sorry, but jQuery wasn\'t able to load';
        } else {
          msg='This page is now jQuerified with v' + jQuery.fn.jquery;
          if (otherlib) {msg+=' and noConflict(). Use $jq(), not $().';}
        }
        return showMsg();
      });
      function showMsg() {
        el.innerHTML=msg;
        b.appendChild(el);
        window.setTimeout(function() {
          if (typeof jQuery=='undefined') {
            b.removeChild(el);
          } else {
            jQuery(el).fadeOut('slow',function() {
              jQuery(this).remove();
            });
            if (otherlib) {
              $jq=jQuery.noConflict();
            }
          }
        } ,2500);
      }
    })();



Wednesday, August 7, 2013

SQL Lookup logged in users

0 comments


exec sp_who2


select d.name, d.dbid, spid, login_time, nt_domain, nt_username, loginame
  from sysprocesses p inner join sysdatabases d on p.dbid = d.dbid
 where d.name = 'DBNAME'

SQL Free up busy database resources

0 comments

use master
ALTER DATABASE im_test_restore SET SINGLE_USER WITH ROLLBACK IMMEDIATE
  
use im_test_restore;
go
 
checkpoint;
go
 
use master;

go
  
ALTER DATABASE im_test_restore SET MULTI_USER