Thursday, 6 February 2020

What is SELF JOIN and when would you use it?

A self join is simply when you join a table with itself. There is no SELF JOIN keyword, you just write an ordinary join where both tables involved in the join are the same table. One thing to notice is that when you are self joining it is necessary to use an alias for the table otherwise the table name would be ambiguous.
A self-join can be an inner join or an outer join. A table is joined to itself based upon a field or combination of fields that have duplicate data in different records. The data-type of the inter-related columns must be of the same type or needs to cast them in same type.
It is useful when you want to correlate pairs of rows from the same table, for example a parent - child relationship.
Some practical uses of SELF JOIN are to obtain running counts and totals, identify which data under a particular column satisfy a certain set of conditions, and generate another table by extracting data from the original table. 

select * FROM Table t1, Table t2 WHERE t1.Id = t2.ID

Example: Using SELF JOIN to find the products supplied by more than one vendor.

Because this query involves a join of the ProductVendor table with itself, two different aliases (pv1 and pv2) are used in the FROM clause. These aliases are used to qualify the column names in the rest of the query.

Syntax:
SELECT DISTINCT pv1.ProductID, pv1.VendorID
FROM Purchasing.ProductVendor pv1
INNER JOIN Purchasing.ProductVendor pv2
ON pv1.ProductID = pv2.ProductID
AND pv1.VendorID <> pv2.VendorID
ORDER BY pv1.ProductID

Why we use SSIS?

Here, are key reasons for using SSIS tool:

  • SSIS tool helps you to merge data from various data stores
  • Automates Administrative Functions and Data Loading
  • Populates Data Marts & Data Warehouses
  • Helps you to clean and standardize data
  • Building BI into a Data Transformation Process
  • Automating Administrative Functions and Data Loading
  • SIS contains a GUI that helps users to transform data easily rather than writing large programs
  • It can load millions of rows from one data source to another in very few minutes
  • Identifying, capturing, and processing data changes
  • Coordinating data maintenance, processing, or analysis
  • SSIS eliminates the need of hardcore programmers
  • SSIS offers robust error and event handling

What is SSIS?

SQL Server Integration Service (SSIS) is a component of the Microsoft SQL Server database software that can be used to execute a wide range of data migration tasks. SSIS is a fast & flexible data warehousing tool used for data extraction, loading and transformation like cleaning, aggregating, merging data, etc.
It makes it easy to move data from one database to another database. SSIS can extract data from a wide variety of sources like SQL Server databases, Excel files, Oracle and DB2 databases, etc.
SSIS also includes graphical tools & wizards for performing workflow functions like sending email messages, FTP operations, data sources, and destinations.

Sunday, 12 June 2016

Difference between Viewstate and Sessionstate ?

 Session state is saved on the server, View State is saved in the page.

View State

1.View state is maintained in page level only .
2.View state information stored in client only.
3.View state persist the values of particular page in the client when post back operation done.  
4.Simple implementation View state does not require any custom programming to use.
5.No server resources are required The view state is contained in a structure within the page code.
6.If ViewState grows larger, it affects the performance of garbage collection. 

Session State:

1.Session state is maintained in session level .
2.Sessioan state value is available in all pages within a user session.
3.Session stae information stored in server.
4.A session is defined as a period of time that is shared between the web application and the user. Each user that is using the web application has their own session. 
5.SessionState variables are cleared, when the user session times out. The default is 20 minutes. This is configurable in web.config

 Usage: If you're going to store information that you want to access on different web pages, you can use SessionState If you want to store information that you want to access from the same page, then you can use Viewstate.   

Storage The Viewstate is stored within the page itself (in encrypted text), while the Sessionstate is stored in the server.

Monday, 30 May 2016

Differences Between Hashtable and Dictionary

Dictionary:

  • Dictionary returns error if we try to find a key which does not exist.
  • It is faster than a Hashtable because there is no boxing and unboxing.
  • Only public static members are thread safe.
  • Dictionary is a generic type which means we can use it with any data type.

Hashtable:

  • It returns null if we try to find a key which does not exist.
  • It is slower than dictionary because it requires boxing and unboxing.
  • All the members in a Hashtable are thread safe,
  • Hashtable is not a generic type,

Reference:

http://www.c-sharpcorner.com/blogs/differences-between-hashtable-and-dictionary1

Wednesday, 28 October 2015

What are windows services? How are they differ from other .NET application? How to create Windows Service in c# ?

Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface. These features make services ideal for use on a server or whenever you need long-running functionality that does not interfere with other users who are working on the same computer.


The main difference between a service and an ordinary windows app
  • Services always run (usually started when computer boots; depending on design, you can manually stop or start these)
  • Services have no UI (If you want to show UI from a service, you need to do it via a separate process) and mostly do not interact directly with users
  • Services run in a separate Windows session (mostly, session 0) and, therefore, are (most always) shared between all users of a computer
  • Services may offer recovery actions (what to do on first, second, and subsequent failures)
  • Services are a bit harder to write and especially to debug. Thus, if thinking of writing a service, please consider console app + scheduled task first windows service vs scheduled task
Refer below link :
http://www.aspdotnet-suresh.com/2011/06/creating-windows-service-in-c-or.html

http://www.csharp-examples.net/create-windows-service/

Saturday, 24 October 2015

Fibonacci series

Before start the programming you need to know exactly what is the Fibonacci series, why it comes around the world??



Golden mean:



Program:
/* Fibonacci Series c language */
#include<stdio.h>
 
int main()
{
   int n, first = 0, second = 1, next, i;
 
   printf("Enter the number of terms\n");
   scanf("%d",&n);
 
   printf("First %d terms of Fibonacci series are :-\n",n);
 
   for ( i = 0 ; i < n ; i++ )
   {
      if ( i <= 1 )
         next = i;
      else
      {
         next = first + second;
         first = second;
         second = next;
      }
      printf("%d\n",next);
   }
 
   return 0;
}

Output:


How to improve applications performance which is hosted in cloud ?

Improving the performance of an application hosted in Microsoft Azure involves a combination of optimizing your application code, leveraging...