Friday, October 19, 2012

Remove Duplicate Data from Sql-server 2005



First Declare a temp table
DECLARE @table Table(column1 INT, Column2 INT, total int)

insert duplicate data to temp table
insert INTO @table SELECT column1, Column2,count(*) FROM Catalogue.MailingListCategoryContacts GROUP BY column1, Column2 HAVING count(*) > 1

Delete from all the data from original table
DELETE FROM Catalogue.MailingListCategoryContacts WHERE column1 IN (SELECT column1 FROM @table)

again insert into the original table
INSERT INTO Catalogue.MailingListCategoryContacts(column1, Column2) SELECT column1, Column2 FROM @table

Wednesday, September 5, 2012

Getting subject added to the mailto command

<a href="mailto:test@example.com?subject=testing%20out%20mailto&body=Just%20testing">Second Example</a>
Example : click here to view the demo

Saturday, April 14, 2012

how to add A DAY IN DATE, SQL-SERVER

DATEADD(type, value, date)
  • date is the date you want to manipulate
  • value is the integere value you want to add (or subtract if you provide a negative number)
  • type is one of:
    • yy, yyyy: year
    • qq, q: quarter
    • mm, m: month
    • dy, y: day of year
    • dd, d: day
    • wk, ww: week
    • dw, w: weekday
    • hh: hour
    • mi, n: minute
    • ss or s: second
    • ms: millisecond
    • mcs: microsecond
    • ns: nanosecond
SELECT DATEADD(dd, 1, GETDATE()) will return a current date + 1 day

Thursday, May 26, 2011

What is the difference between abstraction and encapsulation?

Abstraction:
Abstraction lets you focus on what the object does instead of how it does it

That means we use the object without knowing the source code of the class.

Encapsulation:
Encapsulation means hiding the internal details or mechanics of how an object does something.

Encapsulation is wraping data into single unit.


Wednesday, May 18, 2011

What is the difference between classes and structs in Microsoft.Net?

  • A struct is a value type, while a class is a reference type.
  • When we instantiate a class, memory will be allocated on the heap. When struct gets initiated, it gets memory on the stack.
  • Classes can have explicit parameter less constructors. But structs cannot have this.
  • Classes support inheritance. But there is no inheritance for structs. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Like classes, structures can implement interfaces.
  • We can assign null variable to class. But we cannot assign null to a struct variable, since structs are value type.
  • We can declare a destructor in class but can not in struct.

Saturday, May 14, 2011

Sql-Server, find Duplicate Rows with Count

select Count(ID), Name, Email,Comment
FROM TableName     
group by Name, Email,Comment
having Count(ID)>1

Saturday, March 26, 2011

How to use cufon.replace inside UpdatePanel?


Place below code inside Update Panel 
 
<script type="text/javascript" language="javascript">
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
  function EndRequestHandler(sender, args)
  {
   Cufon.replace('h1');
   Cufon.now();  
 }
<script>

Saturday, March 12, 2011

how can I jump to the top of page using UpdatePanel?


<script type="text/javascript" language="javascript">
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
  function EndRequestHandler(sender, args)
  {
  scrollTo(0,0);
  }
<script>

Monday, March 7, 2011

Difference between JOIN and INNER JOIN

SELECT * FROM table JOIN otherTable ON table.ID = otherTable.FK

OR

SELECT * FROM table INNER JOIN otherTable ON table.ID = otherTable.FK

They function the same. INNER JOIN can be a bit more clear to read, especially if your query has other join types (e.g. LEFT or RIGHT) included in it.

Similarly with OUTER JOINs the word "OUTER" is optional, its the LEFT or RIGHT keyword that makes the JOIN an "OUTER" JOIN.

However for some reason I always use "OUTER" as in LEFT OUTER JOIN and never LEFT JOIN, but I never use INNER JOIN but rather I just use "JOIN"

Monday, October 18, 2010

Sql - server - Find Last updated stored procedures

SELECT name, create_date, modify_date
FROM sys.objects
WHERE type = 'P'
ORDER BY modify_date desc, create_date desc