Tuesday, November 4, 2014

How to drop all stored procedures at once in SQL Server database?


 declare @procName varchar(500)  
 declare cur cursor   
 for select [name] from sys.objects where type = 'p'  
 open cur  
 fetch next from cur into @procName  
 while @@fetch_status = 0  
 begin  
   exec('drop procedure ' + @procName)  
   fetch next from cur into @procName  
 end  
 close cur  
 deallocate cur  

Sunday, November 2, 2014

What is the test card credentials for verifying the payment option in EBS TEST mode?


 
 Card No: 4111 -1111 - 1111 - 1111  
 Exp Date: 07/2016  
 CVV: 123  
 Name of the Issuing Bank: EBS  


Note: No other Card number would be accepted by the Gateway in test phase.

Tuesday, October 28, 2014

How to delete duplicate rows in SQL Server 2008

Imagine that you have a table like:
create table T (
    id int identity,
    colA varchar(30) not null,
    colB varchar(30) not null
)
Then you can say something like:
delete T
from T t1
where exists
(select null from T t2
where t2.colA = t1.colA
and t2.colB = t1.colB
and t2.id <> t1.id)
Another trick is to select out the distinct records with the minimum id, and keep those:
delete T
where id not in
(select min(id) from T
group by colA, colB)

Random Number Between 2 Double Numbers


 public double GetRandomNumber(double minimum, double maximum)  
 {   
   Random random = new Random();  
   return random.NextDouble() * (maximum - minimum) + minimum;  
 }